Support Forum

Disable breadcrumbs

JS Jakob Smith
Jakob Smith
Member

I’m using SP 5.1.3

Is it possible to disable the breadcrumbs in any other way than with “display: none;” in CSS? On the site, where I’m integrating SP I already have a breadcrumb which works well.

Searching this forum, I saw it mentioned that you can control the breadcrumbs settings:

https://simple-press.com/support-forum/sp4/need-breadcrumbs-in-horizontal-bar-not-vertical/#p89921

But I can’t find this page in the SP admin pages.

20 Answers

New Answer

MP Mr Papa
Mr Papa
Member

You referenced a v4 page which is obsolete in v5… in v5 with themes, most display elements are controlled by your sp theme… so you can completely control the layout and display by adding, removing or moving various elements around…

In this case, you just want to remove the template function that displays the breadcrumbs… so for the wp theme you are using, look in the template files folder for one called spHead.php… and find this function:

sp_BreadCrumbs(‘tagClass=spLeft spBreadCrumbs&tree=1’, __sp(‘Home’));

and remove it… you may want to remove any sections holding it too if its the only element in the section…

please note, we highly recommend you make your own sp theme and not edit one of ours to keep from losing changes on upgrade… please see:

http://codex.simple-press.com/codex/themes/theme-basics/creating-a-theme/

JS Jakob Smith
Jakob Smith
Member

Thanks for a very useful reply.

I found the code in spHead.php and removed it. I’m then reusing the function in a code widget, which I’m displaying in my breadcrumb widget area. On the forum page I’m not displaying the normal breadcrumb widget, but instead the widget with this code in it:

<?php
        sp_BreadCrumbs('tree=0', __sp('Home'));
?>

Am I able to control which divider to use? I would like to use an HTML arrow: →

This is really cool because I can emulate the normal breadcrumb with this on the forum pages.

I’m using Display Widgets to control on which pages to show the widgets-

Right now I’m testing, but on the live site I will definitely make my own sp theme, as suggested by you.

YS Yellow Swordfish
Yellow Swordfish
Member

Looking at the breadcrumbs code I see that currently it will only use an actual icon/image file. But the idea that it could use a character as you suggest is not such a bad idea so I will submit it as a possible addition.

JS Jakob Smith
Jakob Smith
Member

Is there any way that I can implement it now?

Or can you point me to where the divider is inserted, so I can implement an ad-hoc solution?

MP Mr Papa
Mr Papa
Member

In file simple-press/forum/content/sp-common-functions.php you will find the referenced breadcrumbs display template function. You can edit and replace the icon with text.

Or you could use the filter in the function but that would require more code, but be upgrade safe.

We have opened a ticket to make this an option which hopefully can make in next release. On Sep 7, 2012 7:36 PM, “Simple:Press Support” wrote:

> > >

JS Jakob Smith
Jakob Smith
Member

Thanks! I think I will figure it out. I’ll report back on the result.

Thanks for making it a ticket.

MP Mr Papa
Mr Papa
Member

okay, cool… need to run out for half day, but will check back and see if you need anything else..

JS Jakob Smith
Jakob Smith
Member

Okay, I would like some help on how to use the filter on this.

Would that be the sph_BreadCrumbs_args filter?

I guess it would be something like “Replace HTML code for the link to the breadcrumb divider with the HTML code for a right arrow”.

Hmm, and probably related to the “icon” argument in sp_BreadCrumbs() which is set to “sp_ArrowRight.png”.

MP Mr Papa
Mr Papa
Member

No, that’s the wrong one. Look at end of function – same name but without ‘args’ in name.

This filter will give you the display code before it’s echoed out.

You can thus change it before displayed. In this case you would want to replace the image tags with straight text/problem-with-post-edit-buttontml, likely with a preg_replace() call.

As I said, in this case it’s a bit harder and needs php code. I suspect you could Google how to replace img tags with text and find it. As I am away from computer until evening I cannot look up the regex until then.

You could directly edit the function more easily but would lose changes on next upgrade.

JS Jakob Smith
Jakob Smith
Member

I’ve had my first turn of luck with this code in my themes spFunctions.php:

function BreadCrumb_Divider_Replace ($breadCrumbs) {
    $icon_replace_with = " → ";
    $breadCrumbs = preg_replace('/<img[^>]+>/i', $icon_replace_with, $breadCrumbs);
    return $breadCrumbs;
}

add_filter('sph_BreadCrumbs', 'BreadCrumb_Divider_Replace');

The arrows though becomes a part of the links, and there is no spacing, so that’s the next thing I need to figure out. it looks like this:

Breadcrumb look

And the generated HTML:

<div id="spBreadCrumbs" class="spBreadCrumbs">
<a class="spLink" href="http://spv2.omkalfatring.dk/"> → Hjem</a><a class="spLink" href="http://spv2.omkalfatring.dk/forum/"> → Forum</a><a class="spLink" href="http://spv2.omkalfatring.dk/forum/okonomi/"> → Økonomi</a></div>
MP Mr Papa
Mr Papa
Member

cant see all the code in the email on my phone, but looks like your preg_replace might be replace more than just img tags??

will look closer this evening when home if you dont figure it out…

JS Jakob Smith
Jakob Smith
Member

Well, the current code in sp-common-view-functions.php places the breadcrumb icon HTML inside the links, so any replacement will also be put there.

My solution for now is:

1) Remove the images from the breadcrumb with the filter (slightly adjusted):

function BreadCrumb_Divider_Replace ($breadCrumbs) {
    $icon_replace_with = "";
    $breadCrumbs = preg_replace('/<img[^>]+>/i', $icon_replace_with, $breadCrumbs);
    return $breadCrumbs;
}

add_filter('sph_BreadCrumbs', 'BreadCrumb_Divider_Replace');

2) Edit lines 1238, 1255, 1265, 1274 and 1280 of sp-common-view-functions.php, placing the → HTML entities in the link code there.

I know 2 is not upgrade-safe, but it’s an okay solution for now. After an upgrade it would not take long to correct the code.

Still, I would appreciate the possibility to add the arrows as a divider-argument in sp_BreadCrumbs().

MP Mr Papa
Mr Papa
Member

so if I understand, you are good for now?

As I said, we hope to implement the ticket for allowing text (or html entity) as the separator in the next version…