Page 1 of 1

title bar behaviour of archive consulting within a category

Posted: Thu May 25, 2006 4:37 am
by nbar
Hi,

When I am viewing the entries of a category the title bar displays CATEGORY - BLOGTITLE. If I then go to the archives I only get entries of that category. So far so good, I would expect that behaviour.

The problem is that, in such a case, I am consulting the archives of a particular category but that doesn't reflect on the title bar which changes to BLOGTITLE - ARCHIVE MONTH/YEAR, and I lose track of the category I'm in (even worse, a user that is not aware of that feature might think that there are only entries of that type for the refered months).

Is there a way to change the title to CATEGORY - ARCHIVE MONTH/YEAR in such situations?

Thank you,

nbar

Re: title bar behaviour of archive consulting within a categ

Posted: Fri May 26, 2006 1:58 pm
by garvinhicking
Hi!

Yes, that should be possible.

Whenever you're in "category" viewing mode, those Smarty variables are set:

Code: Select all

{$category_info}
{$category}
$category holds the ID of the current category. {$category_info} is an array that holds the keys {$category.info.category_name} for example.

So with that you should be able to patch up your index.tpl file?

If you have more questions, please ask! :)

Regards,
Garvin

Posted: Mon May 29, 2006 10:47 pm
by nbar
Thank you for your quick reply. Let me try it and I'll post the patch as soon as I'm done (hopefully).

Regards,

nbar

Posted: Fri Jun 02, 2006 6:20 am
by nbar
So here is my solution. But first i need to state the problem clearly.

I want the following behaviour on the banner titles:

- the blog title is always the Head Title (HT)
- in a category the category name is Head Subtitle (HST)
- in an archive the category name is HST (if we are within a category) and the month-year is beneath it (the month-year appears as HST if we are not in a category archive)
- in a static page the name of the page is HST
- in an article its category is HST (no article name as title)

The soluiton I came up with is a bit clumsy but works. I've checked in each situations which variables were defined and used that trick to get what I wanted... Here is the code:

Code: Select all

<!-- if it's the blog title then i want the usual behaviour reversed-->
{if $head_subtitle == $blogTitle and ($staticpage_headline or $category_info.category_name)}
    <a class="homelink1" href="{$serendipityBaseURL}">{$head_subtitle}</a><br>
    <a  class="homelink2" href="{$serendipityBaseURL}">{$head_title}</a>
{else}
    <!-- if it's defined and it's not the blog title then it's and archive date -->
    {if $head_subtitle and $head_subtitle != $blogTitle}
         <!-- check if it's an archive within a category -->
         {if $category_info.category_name}                                                                                                                                                          
         <a class="homelink1" href="{$serendipityBaseURL}">{$blogTitle}</a><br>
         <a  class="homelink2" href="{$serendipityBaseURL}">{ $category_info.category_name}</a><br>
         <a  class="homelink2" href="{$serendipityBaseURL}">_{$head_subtitle}</a>
        <!-- archive without category -->
        {else}
        <a class="homelink1" href="{$serendipityBaseURL}">{$blogTitle}</a><br>
        <a  class="homelink2" href="{$serendipityBaseURL}">_{$head_subtitle}</a>
        {/if}
    <!-- there is no date to show -->
    {else}
        <!-- but there might be a category name -->
        {if $category_info.category_name}
        <a class="homelink1"href="{$serendipityBaseURL}">{$head_subtitle|@default:$blogTitle}</a><br>
        <a  class="homelink2" href="{$serendipityBaseURL}">_{ $category_info.category_name}</a>
        {else}
        <a class="homelink1" href="{$serendipityBaseURL}">{$head_subtitle|@default:$blogTitle}</a>
        {/if}
    {/if}
{/if}
There is certainly a much clever way of handling all the if_then_else but I needed a fast solution. I would also like a nicer way of doing all this by defining directly the HT and HST variables... just for the sake of nice programming!

Thank you,

nbar

Posted: Fri Jun 02, 2006 1:55 pm
by garvinhicking
Hi!

You might want to look at the new "{$view}" smarty variable that was introcduced to recent 1.0 and 1.1 versions (snapshots only, though - the actuall release will be made later next week).

This variable contains "archive" or "categories" or whatever else and indicates the page you are currently viewing...

Best regards,
Garvin