[solved] changing hometitles

Having trouble installing serendipity?
Post Reply
.g@sp.
Regular
Posts: 50
Joined: Thu Apr 20, 2006 2:01 pm
Location: Brussels, Belgium

[solved] changing hometitles

Post by .g@sp. »

hi

i'm looking for the way to set my homelinks...
i've that :

Code: Select all

<div id="serendipity_banner">
    <h1><a class="homelink1" href="{$serendipityBaseURL}">{$head_title|@default:$blogTitle}</a></h1>
    <h2><a class="homelink2" href="{$serendipityBaseURL}">{$head_subtitle|@default:$blogDescription}</a></h2>
</div>
when a user is reading a post i would have the parent categorie on homelink1 and the subcat on homelink2 (i don't care of the link itself, just what it's write)
i've activated the smarty template, i'm sure it could help...

if someone could help me, it would be great ;)
Last edited by .g@sp. on Mon Apr 24, 2006 10:01 am, edited 1 time in total.
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

That's in the index.tpl, as you seem to have found. Changing it is going to require a bit of work.

First, to only change it when looking at an individual post, wrap an if around it testing $is_single_entry.

Parents and subcategories I can't do, but I can pull off the first category for this entry. It's ugly, but it can be done. Putting it all together, you'd get:

Code: Select all

<div id="serendipity_banner">
{if $is_single_entry}
    <h1><a class="homelink1" href="{$serendipityBaseURL}">
{* There's only going to be one entry, but there's no way to know what its index is, so we have to use foreach *}
{foreach from=$entries item="dategroup"}
{foreach from=$dategroup.entries item="entry"}
  {$entry.categories[0]|@default:$blogTitle}</a></h1>
{/foreach}
{/foreach}
{else}
<h1><a class="homelink1" href="{$serendipityBaseURL}">{$head_title|@default:$blogTitle}</a></h1>
{/if}
    <h2><a class="homelink2" href="{$serendipityBaseURL}">{$head_subtitle|@default:$blogDescription}</a></h2>
</div>
I think that should do it. Let me know if you have any trouble.
Judebert
---
Website | Wishlist | PayPal
.g@sp.
Regular
Posts: 50
Joined: Thu Apr 20, 2006 2:01 pm
Location: Brussels, Belgium

Post by .g@sp. »

ok thanks, i'll try it now ;)

what does mean $entry.categories[0] ??
because with the plugin_categorie.tpl, i've this : <li class="depth{$plugin_category.depth}" style="display: block;">
it can't help to do what i want ?

the index.tpl file, i've to put it in my theme dir ?


(sorry, i just begin with s9y, i don't really understant how it works for now :? )
Sorry for my poor english ;)
.g@sp.
Regular
Posts: 50
Joined: Thu Apr 20, 2006 2:01 pm
Location: Brussels, Belgium

Post by .g@sp. »

ok i've tried it, but it doesn't really work... the homelink1 shows "Array" :shock: when i'm on a post

In fact i think i didn't well explain what i want (and it was wrong) :
it's not only when the user is reading a post that i want my homelinks to change... it's not easy to tell it in english, but i'll try...

- when a visitor comes to index page :
it's ok (hl1 = blog title, no hl2)
- when a visitor is into a parent categorie :
it's ok (hl1 = parent categorie name, hl2 = blogtitle)
- when a visitor is into a subcategorie :
not ok (it's hl1 = categorie name, hl2 = blog title, i'd like to have hl1 = parent categorie name, hl2 = categorie name)
- when a visitor is reading an entry :
not ok (it's hl1 = entry name, hl2 = blog title, i'd like to have h1 = categorie name, hl2 = entry name)

hope it's clearer...

If it's not possible don't be afraid to tell me ;)

thanks for helping
Sorry for my poor english ;)
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

- when a visitor is into a subcategorie :
not ok (it's hl1 = categorie name, hl2 = blog title, i'd like to have hl1 = parent categorie name, hl2 = categorie name)
This is one of the things that needs coding to work. The parent category just isn't set anywhere, so the template can't use it.

On the other hand, we could kludge around it: install the category-templates plugin, then make a different index.tpl for each subcategory, using its parent in the hl1.
- when a visitor is reading an entry :
not ok (it's hl1 = entry name, hl2 = blog title, i'd like to have h1 = categorie name, hl2 = entry name)
This is possible, and the current "Array" thing is a problem in the code I handed you. It's partly related to this:
what does mean $entry.categories[0] ??
because with the plugin_categorie.tpl, i've this : <li class="depth{$plugin_category.depth}" style="display: block;">
it can't help to do what i want ?
$entry.categories[0] means "the string in index 0 of the 'categories' portion of the entry array". Unfortunately, it's returning an array. I thought it would return a string, with the category name. To get the name, just use $entry.categories[0].category_name instead.

For the final question: the plugin_categories.tpl is only used to style the category template sidebar box, so the $plugin_category.depth isn't going to help out. It really just specifies how many parents that category has, anyway. (On the other hand, the category sidebar box may define other variables that could help us. I just don't know what they are.
Judebert
---
Website | Wishlist | PayPal
.g@sp.
Regular
Posts: 50
Joined: Thu Apr 20, 2006 2:01 pm
Location: Brussels, Belgium

Post by .g@sp. »

- when a visitor is reading an entry :
almost ok ( now it's hl1 = categorie name, hl2 = blog title, i'd like to have h1 = categorie name, hl2 = entry name)
i know it could be possible, i had the entry name in hl1 just before that...
if i knew where to find that kind of things in the code, but i'm really lost :?
something like $entry.name ??
Sorry for my poor english ;)
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Your English is better than my German (or anything else, for that matter); it's not a problem.

The template snippet I gave you should work, if you change the $entry.categories[0] to $entry.categories[0].category_name -- that'll give you the name of the first category this entry belongs to. If there are multiple categories, they'll be ignored.

The entry name itself is already used in entries.tpl. Looking in there, I see the name is in $entry.title.

Good luck!
Judebert
---
Website | Wishlist | PayPal
.g@sp.
Regular
Posts: 50
Joined: Thu Apr 20, 2006 2:01 pm
Location: Brussels, Belgium

Post by .g@sp. »

wonderfull 8)

here is the code

Code: Select all

<div id="serendipity_banner">
{if $is_single_entry}
    <h1><a class="homelink1" href="{$serendipityBaseURL}">
{* There's only going to be one entry, but there's no way to know what its index is, so we have to use foreach *}
{foreach from=$entries item="dategroup"}
{foreach from=$dategroup.entries item="entry"}
  {$entry.categories[0].category_name|@default:$blogTitle}</a></h1>
 <h2><a class="homelink2" href="{$entry.link}">{$entry.title}</a><h2>
{/foreach}
{/foreach}
{else}
<h1><a class="homelink1" href="{$serendipityBaseURL}">{$head_title|@default:$blogTitle}</a></h1>
<h2><a class="homelink2" href="{$serendipityBaseURL}">{$head_subtitle|@default:$blogDescription}</a></h2>
{/if}
    
</div> 
Hope it could help someone later...

Thank you very much

anyway... i'm french speaker ;)
Sorry for my poor english ;)
Post Reply