Breadcrumb

Skinning and designing Serendipity (CSS, HTML, Smarty)
vastneonwolf
Regular
Posts: 43
Joined: Sun May 22, 2005 6:57 am
Contact:

Breadcrumb

Post 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?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Breadcrumb

Post by garvinhicking »

The only way would be to modify the staticpage plugin to assign smarty variables which you can later read...

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
vastneonwolf
Regular
Posts: 43
Joined: Sun May 22, 2005 6:57 am
Contact:

Post by vastneonwolf »

Thanks, I'll look into it :)
vastneonwolf
Regular
Posts: 43
Joined: Sun May 22, 2005 6:57 am
Contact:

Post by vastneonwolf »

Any chance you could give me a hint on how to assign smarty variables? :)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
vastneonwolf
Regular
Posts: 43
Joined: Sun May 22, 2005 6:57 am
Contact:

Post by vastneonwolf »

Thanks very much!
Still learning about Smarty :)
vastneonwolf
Regular
Posts: 43
Joined: Sun May 22, 2005 6:57 am
Contact:

Post 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>
MySchizoBuddy
Regular
Posts: 340
Joined: Sun Jun 12, 2005 5:28 am

Post 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.
vastneonwolf
Regular
Posts: 43
Joined: Sun May 22, 2005 6:57 am
Contact:

Post 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.
MySchizoBuddy
Regular
Posts: 340
Joined: Sun Jun 12, 2005 5:28 am

Post 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.
vastneonwolf
Regular
Posts: 43
Joined: Sun May 22, 2005 6:57 am
Contact:

Post by vastneonwolf »

Just add serendipity_breadcrumb to your style sheet.
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply