wet-boew/wet-boew-php

Breadcrumb trail enhancment

upsonp opened this issue · 4 comments

I'd like to add an enhancement to the PHP variant breadcrumb trail generator. At the moment the way the breadcrumb trail is generated is by looking for bt_fa.php files within a directory and then finding bt_fa.php files in parent directories.

The bt_fa.php file looks something like:

<?php
$_NAVPATH['title_eng'] = "Otolith Research Lab";
$_NAVPATH['title_fra'] = "Le Laboratoire de recherche sur les otolithes";
$_NAVPATH['link_eng'] = "/otoliths/index-eng.php";
$_NAVPATH['link_fra'] = "/otoliths/index-fra.php";

?>

Background

The big downfall with the current breadcrumb generator method is breadcrumbs are dependent on where a "subsite" lies in the directory structure. With the above example Otoliths was originally under /science/research-recherche/fisheries-pecheries/otoliths/ on my site. The content owner really wanted the URL to be much shorter for the site, aliasing isn't an option for me, so I moved Otoliths to /science/otoliths/. The navigation to get to the "subsite" from the megamenu and leftside is still the same, but the breadcrumb only shows as (BIO Home > Otoliths) where it should be (BIO Home > Research > Otoliths)

Proposal

I'd like to modify the breadcrumb generator to allow a bt_fa.php file to specify an array to allow more refined control for PHP developers to specify what goes in the trail. The current method as in the example above will still work, but developers will also have the option to use something like:

<?php
$_NAVPATH['title_eng'][0] = "Research";
$_NAVPATH['title_fra'][0] = "Recherche";
$_NAVPATH['link_eng'][0] = "/science/research-recherche/index-eng.php";
$_NAVPATH['link_fra'][0] = "/science/research-recherche/index-fra.php";

$_NAVPATH['title_eng'][1] = "Otolith Research Lab";
$_NAVPATH['title_fra'][1] = "Le Laboratoire de recherche sur les otolithes";
$_NAVPATH['link_eng'][1] = "/otoliths/index-eng.php";
$_NAVPATH['link_fra'][1] = "/otoliths/index-fra.php";
?>

This allows the developer to create an array the breadcrumb generator will use to add additional elements to the trail without requiring a "subsite" to reside under a specific directory.

I suggest that you might add this in your help page and not on the actual code.

For now i don't plan having a subsite ... maybe in the futur but they will have their one folder in the root ...

So I think is more "personnal modification" than general.

@crochefort thanks for the input, I definitely will be adding this to the help.

It is more specific to me because the site I maintain is pretty big with a lot of unrelated sub topics. I've had to be really careful up to now to keep things in a strict directory structure so the breadcrumbs would work properly.

However with this suggestion we will be able to use the bt_fa.php file in two different ways. The way we are currently using it would still work as is so there is no need to do anything different if you don't need the function.

If in the future you did require it you could make a small change to a bt_fa.php file and add links to the breadcrumb if you needed to.

As it is now the breadcrumb cannot be modified to add additional links if needed, which can be done with core WET when pages are in plain HTML.

Where do you plan on storing this bt_fa.php file?

Instead of having a setting that you can turn on or off, could you just expect the path to the file to be in a variable which I could override in my settings? The default should naturally be an empty string unless otherwise defined and your code should check for the existence of the file before it tries to use it.

What this will accomplish is:

  • Have different bt_fa.php files for different sections of the site or different purposes.
  • Avoid having to modify a file included in the WET-BOEW-PHP directory structure - I can put it anywhere.
  • Give people the option to statically set or dynamically manage the code generated by bt_fa.php.

One use I could see for this would be to dynamically alter the breadcrumb trail depending on the referrer page. For example, if I understand what you are proposing, I could have the same Multimedia Help page available under a variety of different topics and it would actually show up that way in the breadcrumb so that users could retrace their path back to that page the way they actually got there.

For the more visual:

Home
+- Video 1
| +- Multimedia help
|- Video 2
| +- Multimedia help
|- Video 3
| +- Multimedia help

Normally if I clicked on Home > Video 1 > Multimedia Help, the breadcrumb should show something like:

Home > Multimedia Help

...which is where the help file actually resides and doesn't really represent a trail of breadcrumbs showing you how you got to that page.

Using a dynamic bt_fa.php which takes into consideration the referrer page, I could have the breadcrumb trail show this instead:

Home > Video 1 > Multimedia Help

All that being said, I like the idea of also retaining the old system for very basic sites that are organized in a structured folder system.

I think I see where the confusion is, I just noticed the breadcrumb generator is actually called "bt_fa.php". located /wet-boew-php/dist-php/inc/bt_fa.php. The file should probably be renamed to something more intuitive to eliminate the confusion of when we're talking about breadcrumb files, site specific and modifiable, and the actual generator in the /wet-boew-php/dist-php/inc/ folder which uses the bt_fa.php files throughout the site.

Basically the changes I'm proposing to the generator in /wet-boew-php/dist-php/inc/ would allow us to do exactly what @michael-milette laid out.

You should have the option to

  • leave the breadcrumbs the way it currently works using $_NAVPATH['title_'] and $_NAVPATH['link_']
  • Manually specify a breadcrumb trail by turning $_NAVPATH in to an array ($_NAVPATH['title_'][0] and $_NAVPATH['link_'][0], $_NAVPATH['title_'][1] and $_NAVPATH['link_'][1], ..., $_NAVPATH['title_'][n] and $_NAVPATH['link_'][n])
  • or dynamically generate them with magic of some kind, probably by using $_NAVPATH as an array, but generating the elements from PHP variables like referrer page.