Breadcrumbs
Hi All,
I have my site pretty much the way I want it, but I'm having a slight issue modifying the breadcrumbs. I've edited them so that they display the page/thread title, but when someone goes to edit their post, or something else that would already generate a breadcrumb, it's showing "Home › General › Edit Discussion › Edit Discussion"
Is there a way to remove the first Edit Discussion, since it's already listed there where I put it manually?
0
Comments
Welcome to the community!
What version of Vanilla are you running?
How did you implement your current breadcrumb modification?
precisely what i thought.
Sorry for the delayed reply!
{breadcrumbs} <span class="Breadcrumbs" itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><span class="Crumb"> › </span><span itemprop="title">{$Title}</span></span>is what I'm using in default.master.tpl to achieve what I want, hackey I know.We're running on the latest version off the GitHub.
and we say again what version is that? It's not that hard to put a number in, provided you want help.
Apologies. We're running v2.2
Breadcrumbs are wildly diverse in Vanilla.
You could use a theme hook to add the page title as the last breadcrumb only if it would be different.
Something like:
public function Base_Render_Before($Sender) { $crumbs =& $Sender->Data['Breadcrumbs']; $crouton = count($crumbs); if($crumbs[$crouton - 1]['Name'] != $Sender->Data['Title']) { $crumbs[$crouton]['Name'] = $Sender->Data['Title']; $crumbs[$crouton]['Url'] = '#'; } }If you use this, you should remove your previous modification to the default.master.tpl file.
{breadcrumbs}is all that is needed.See above. I forgot I can edit posts by clicking on the gear icon that appears when hovering over a post and selecting Edit.
@hgtonight
I got to the themehooks part but never coded anything
, but i was thinking of removing based on post controller or adding if not post controller, but I I like yours better.
Tossed that in and it just made Vanilla start throwing a 500 error
+1 for the try though, I appreciate it! I've never used theme hooks, and not even close to a coder, lol.
in your tpl file - this will print normal breadcrumbs with title you wanted and will not print duplicates of edit discussions. So based on what you said - I believe this is what you want
@stapler2025
{if $Title == "Edit Discussion"} {breadcrumbs} {else} {breadcrumbs} <span class="Breadcrumbs" itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><span class="Crumb"> › </span><span itemprop="title">{$Title}</span></span> {/if}but you didn't mention the problem duplicates everywhere - not just edit discussion, it duplicates categories too.
So hgtonight's solution is better.
try this
@stapler2025
{if ($Discussion.DiscussionID < "1") || ($Title == "Edit Discussion")} {breadcrumbs} {else} {breadcrumbs} <span class="Breadcrumbs" itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><span class="Crumb"> › </span><span itemprop="title">{$Title}</span></span> {/if}I tested it working on 2.1b1, but could you post the full error?
hey @hgtonight
what do you thin about --
http://vanillaforums.org/discussion/comment/187964/#Comment_187964
too restrictive?? it works though - he didn't have a working link before in the title, it seems overkill anyway.
First error was
[19-Jul-2013 02:13:25 UTC] PHP Parse error: syntax error, unexpected T_PUBLIC in /home/lsvps/public_html/vanilla/themes/default/class.defaultthemehooks.php on line 2so I addedclass DefaultThemeHooks implements Gdn_IPlugin {Now I'm getting
[19-Jul-2013 02:14:00 UTC] PHP Parse error: syntax error, unexpected $end, expecting T_FUNCTION in /home/lsvps/public_html/vanilla/themes/default/class.defaultthemehooks.php on line 12Thanks for your guys help
@peregrine - what it's doing with how I have it setup using the title smarty tag, is anything that would already be in the breadcrumb bar, is basically duplicated. So if you're viewing a specific category, it lists Home - CategoryName - CategoryName, or starting a new discussion does Home - New Discussion - New Discussion, etc.
Those errors indicate your theme hooks file is not set up correctly.
Mind posting the contents of your
class.defaultthemehooks.phpfile?<?php if (!defined('APPLICATION')) exit(); class DefaultThemeHooks implements Gdn_IPlugin { public function Base_Render_Before($Sender) { $crumbs =& $Sender->Data['Breadcrumbs']; $crouton = count($crumbs); if($crumbs[$crouton - 1]['Name'] != $Sender->Data['Title']) { $crumbs[$crouton]['Name'] = $Sender->Data['Title']; $crumbs[$crouton]['Url'] = '#'; } }@stapler2025
you may chose to use @hgtonight's solution in the long run.
but doesn't the change i posted in relation to you tpl file work
http://vanillaforums.org/discussion/comment/187964/#Comment_187964
it doesn't duplicate anything as far as I can see
Suuuuuuuper late reply, been busy.
If I'm reading your's right, all it looks for is Edit Discussion, doesn't it?
no , not true.
all I can say is, try it. it worked for me. and if it doesn't work for you tell me exactly what doesn't work.
come back in a couple of weeks
.