Page 1 of 1

Removing last breadcrumb link. OC 2.3

Posted: Tue Aug 01, 2017 7:15 am
by Mosstyn
Hi, Sorry if this is duplicate post, I've had a good search but could not find an answer. I'm looking to remove the link from the last breadcrumb on my information pages.

I.E. For my FAQ page, my breadcrumb would be "Home >> FAQ". I want to keep the 'FAQ' part but remove the link so it's just text.

I've edited my category and product TPL files to actually remove the last breadcrumb as I think this look neater, but for the pages with only two breadcrumbs, I think it looks odd to remove and just have "Home" so thought it better to remove the link if possible.

Thanks in advance.

Re: Removing last breadcrumb link. OC 2.3

Posted: Tue Aug 01, 2017 7:29 am
by thekrotek
Nope, it doesn't look odd with only 2 breadcrumb items. You can safely remove the link for last item on all pages.

Re: Removing last breadcrumb link. OC 2.3

Posted: Tue Aug 01, 2017 4:27 pm
by Mosstyn
But I wouldn't have two items if I removed the last breadcrumb on "Home >> FAQ". I would only have "Home", and I think that would look odd. I would, if possible like to keep the last breadcrumb, but just with no link.

Re: Removing last breadcrumb link. OC 2.3

Posted: Tue Aug 01, 2017 4:47 pm
by thekrotek
I didn't say anything about removing the last item. You shouldn't do this anywhere, not only when thre're only 2 items.

So yes, remove a link from last breadcramb and it will look great. Since you're familiar with TPL files, you'll do it easily. Not sure, what's your issue.

Re: Removing last breadcrumb link. OC 2.3

Posted: Tue Aug 01, 2017 7:25 pm
by Mosstyn
Sorry if I didn't make myself clear, despite my being able to remove the breadcrumbs that I didn't need, removing the hyperlinks seems to be more tricky. But.....it seems to have worked now. Just removing the <a href> elements in the TPL. I must not have refreshed the page properly. Thank you,

Re: Removing last breadcrumb link. OC 2.3

Posted: Wed Aug 02, 2017 6:02 am
by Mosstyn
.....although now none of the breadcrumbs have a hyperlink. So the question remains - how to remove the hyperlink from the last breadcrumb whilst keeping the others?

Re: Removing last breadcrumb link. OC 2.3

Posted: Wed Aug 02, 2017 6:15 am
by thekrotek
Add check for last array key:

Code: Select all

foreach ($breadcrumbs as $key => $breadcrumb) {
    if ($key == (count($breadcrumbs) - 1)) {
        // skip the <a> tag
    }
}

Re: Removing last breadcrumb link. OC 2.3

Posted: Wed Aug 02, 2017 8:12 am
by Mosstyn
Thanks for your patience. Does that go in between the first <?PHP> call and the <li> tag in the TPL?

Re: Removing last breadcrumb link. OC 2.3

Posted: Wed Aug 02, 2017 3:10 pm
by thekrotek
Well... If you edited TPL before, you should've seen this foreach clause already. You just need to edit it a bit.