Page 1 of 2

Breadcrumb

Posted: Sat May 28, 2005 7:47 am
by vastneonwolf
I've just added a "Breadcrumb" to my index.tpl

Code: Select all

<div id="serendipity_breadcrumb">
    <a href="{$serendipityBaseURL}">Home</a> {if $head_title}:: <a href="{$category.category_link}">{$category.category_name}</a> {if $entry.title == $head_title}:: {$entry.title}{/if}{/if}
</div>
The problem is it only tracks categories and articles.
Any idea how I could mack it trackpages created with the static page plugin?

Re: Breadcrumb

Posted: Sat May 28, 2005 1:30 pm
by garvinhicking
The only way would be to modify the staticpage plugin to assign smarty variables which you can later read...

Regards,
Garvin

Posted: Sat May 28, 2005 4:36 pm
by vastneonwolf
Thanks, I'll look into it :)

Posted: Sun May 29, 2005 9:22 am
by vastneonwolf
Any chance you could give me a hint on how to assign smarty variables? :)

Posted: Mon May 30, 2005 11:23 am
by garvinhicking
Sure; you should be able to access

Code: Select all

$serendipity['smarty']->assign('isStaticpage', true);
in the staticpage plugin. You must place it in an event hook where serendipiy_smarty_init() has already been called. The "genpage" hook for example does not yet have it called, thus you should place it in the 'entries_header' place:

Code: Select all

                case 'entries_header':
                    $serendipity['smarty']->assign(array(
                           'isStaticpage' => true,
                           'StaticpageTitle' => $this->get_static('articleformattitle')
                     ));
                    $this->show();

                    return true;
                    break;
This code will let you use this in any of your *.tpl Smarty files:

Code: Select all

{if $isStaticpage}
Staticpage: {$StaticpageTitle}
{/if}
HTH and Regards,
Garvin

Posted: Mon May 30, 2005 11:25 am
by vastneonwolf
Thanks very much!
Still learning about Smarty :)

Posted: Mon May 30, 2005 1:35 pm
by vastneonwolf
Thanks for your help Garvin :)

If anyone is interested here is the updated breadcrumb code...

Code: Select all

<div id="serendipity_breadcrumb">
    <a href="{$serendipityBaseURL}">Home</a>
    {if $head_title && !$entry.title | $head_title != $entry.title}
      :: {$category.category_name}
    {elseif $head_title && $entry.title}
      :: <a href="{$category.category_link}">{$category.category_name}</a>
      {if $entry.title == $head_title}
        :: {$entry.title}
      {/if}
    {/if}
    {if $isStaticpage && !$entry.title}
      :: {$StaticpageTitle}
    {/if}
</div>

Posted: Thu Jun 30, 2005 1:48 pm
by MySchizoBuddy
Thanks guys, Can u tell me where inside index.tpl should i add it.
PLus is that it, or i have to add garvins code as well

Btw some themes have index.tlp and some don't.
why is that, and whats the use of index.tpl.

Posted: Fri Jul 01, 2005 12:12 am
by vastneonwolf
OK I suggest putting it just before the start of the content table in the index.tpl

Code: Select all

<table id="mainpane" cellspacing=0 cellpadding=0>
The index.tpl is how you control the look of your page instead of just using css you have more control over the look and feel.

Posted: Fri Jul 01, 2005 10:06 am
by MySchizoBuddy
sanku
:)
worked
oH u have to remove
the ::
from this line

Code: Select all

:: <a href="{$category.category_link}">{$category.category_name}</a>
else it displays 4 doyts liek this
:: ::

Btw how do u chnage its found, its kinda big and doesn't match my theme.

Posted: Fri Jul 01, 2005 10:17 am
by vastneonwolf
Just add serendipity_breadcrumb to your style sheet.

Posted: Mon Feb 20, 2006 1:31 am
by carl_galloway
I've been working on adding a breadcrumb to one of my unreleased themes, and I notice the static pages links don't work. Looking into my static pages plugin I see that the smarty code mentioned above isn't included.

I want the breadcrumb for a theme and if I change my own plugin files then other users won't be able to benefit from the breadcrumb. Is there any way I could add the smarty above into my theme config file, or does the plugin need to be updated. I'm not worried about BC with this theme because it already uses version one hooks and won't work well with older versions.

Carl

Posted: Mon Feb 20, 2006 11:16 am
by garvinhicking
The problem is that it seems one of your entries.tpl files is overwriting the $category variable within a foreach loop.

You'll need to use a different variable, and I think other themes also need to be fixed for this.

I just committed the fixed templates to SVN, where I replaced $category with $entry_category.

Regards,
Garvin

Posted: Mon Feb 20, 2006 5:19 pm
by carl_galloway
Not sure I follow you Garvin, I'm using the breadcrumb to create a theme from an oswd (andreas06), and started with the default theme (serendipity2.3) so haven't changed any of the variables.

Perhaps I'm too tired to understand properly :?

The part of the breadcrumb code that isn't working is the

Code: Select all

    {if $isStaticpage && !$entry.title}
      :: {$StaticpageTitle}
    {/if}
Carl

Posted: Mon Feb 20, 2006 5:59 pm
by garvinhicking
The bug with using $category within the entries.tpl is also present in the serendipity 2.3 default template. :)

But that is fixed for the 1.0 release. :)

But what you pasted is a different problem. You need to follow the complete thread and need to patch up your staticpage plugin. Without that patch, staticpage breadcrumbs cannot work.

Recent staticpage plugin versions define smarty variable differently. They set "$staticpage_title

"$isStaticpage" should read "$is_staticpage" and "$staticpageTitle" should read $staticpage_pagetitle, I think. You can use the smartycheck

Code: Select all

{if $staticpage_pagetitle}
To check if a staticpage is set, I think.


Best regards,
Garvin