1

Using Joomla 3.9.12 and SP Portfolio v1.7

I have a menu item called Locations, this is a menu item type SP Simple Portfolio » Items

Whenever I visit example.com/locations I can see all my portfolio items, great. If I select one of the portfolio items, e.g. Paris, I am taken to example.com/locations/paris, works as expected.

I have enabled the Joomla breadcrumbs module on this page and it displays;

You are here: Home / Locations / Paris

  • Selecting Home successfully takes me to the home page example.com
  • Selecting Locations takes me to example.com/locations/items - this page doesn't exist so I get a 404 error.

When I select Locations in the breadcrumbs I want to go to example.com/locations.

No idea where the additional /items URL parameter is coming from, I can't see it configured anywhere in my menu setup.

What do I need to do in order to get this working how I want?

  • This seems like an intelligent workaround: yellowwebmonkey.com/developer-blog/item/… . This looks kinda close: joomla.stackexchange.com/q/22827/12352 – mickmackusa Nov 18 '19 at 21:44
  • Do you have any SEF extensions installed? I get completely different results on a clean installation. Clicking on an item takes me to example.com/locations/item/1-paris and breadcrumb only contains Home > Locations. And Locations is not clickable. – Sharky Nov 19 '19 at 7:04
  • @Sharky I don't have any third party SEF extensions installed. Joomshaper have created an override of mod_breadcrumbs I might try to edit this, although I don't think I should have to :/ – jonboy Nov 19 '19 at 9:27
  • Thanks @mickmackusa those are both good suggestions. I'm kind of reluctant to create any url rewrites as it can get messy. I've already tired creating a hidden menu item called items with menu item alias to locations but it doesn't work. I can't understand why the breadcrumbs is displaying /items at all? – jonboy Nov 19 '19 at 9:34
1

I managed to get this working by editing the (already existing Helix / Joomshaper) override.

After spending a (very!) long time trying to figure out where the /items url parameter was coming from, I gave up and modified the override.

I know this isn't a solution but it solves my problem, and possibly someone else that uses the Helix framework or a Joomshaper template.

Add this code to your-template\html\mod_breadcrumbs\default.php, before the foreach block.

array_walk($list, function (&$v) { 
    if ($v->name == 'Items') $v->link = dirname($v->link); 
});

The breadcrumbs code returns an array with name and link keys. This checks the link and if it contains Items, it will be removed.

Working so far..

  • Just so you know, there are a few fundamental differences between arrays and objects. A sneaky difference is that an object doesn't need the & (modify by reference) declaration to remain mutated outside of the array_walk() scope. Have a look at this: 3v4l.org/cbIHX – mickmackusa Dec 21 '19 at 10:01
0

That make me crazy and took long time to solve.

Add rtrim($item->link,"items") before class="pathway".

Detail is as follows:

echo '<a href="' . rtrim($item->link,"items") . '" class="pathway">' . $item->name . '</a>';
  • This technique is generally inadvisable. The second parameter of rtrim() is a character mask. In other words, it is a list of individual characters to remove. It would work identically if the mask was stime. This can lead to unwanted side effects if the last word in the string is not items but contains i, t, e, m, or s. It would be better to specify the literal substring to remove at the end of the string (if it exists). Please take the tour. – mickmackusa Dec 20 '19 at 22:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.