Page 1 of 1
categories' templating & category as "homepage"
Posted: Thu Feb 14, 2008 10:24 pm
by Ramoney
Hello,
Serendipity 1.2.1 with PHP 4.4.7 is causing the following problem:
I do have smarty-templating enabled for categories & chose a single category (ID 1) as the starting page. Everything works perfectly until it comes to display an article/entry in single-entry-view:
a) I choose a category (IDs 1-7) and it is displayed as "active" (it is set in {$category_info}).
b) I chose a single article/entry from any category (IDs 1-7) - category ID 1 is "active" (and set in {$category_info}).
If I set things back to show all entries on the starting page, there's a slighlty different behaviour in b):
No category is active (the array in {$category_info} is empty).
How can I change things, so that in single-entry-view the corresponding category is "active" and set in {$category_info}.
I hope someone can help.
Ramoney
Re: categories' templating & category as "homepage&
Posted: Fri Feb 15, 2008 10:52 am
by garvinhicking
Hi!
Actually, you can't really, because single article view is not a category view.
The solution to this is that you would need an event plugin that sets the category ID depending on inside which category the entry is. I believe the plugin "serendipity_event_categorytemplates" already offers to do that with a config option, it should set the requiered $serendipity['GET']['category'] variables which later populate the $category_info array.
Regards,
Garvin
Re: categories' templating & category as "homepage&
Posted: Fri Feb 15, 2008 3:19 pm
by Ramoney
garvinhicking wrote:I believe the plugin "serendipity_event_categorytemplates" already offers to do that with a config option, it should set the requiered $serendipity['GET']['category'] variables which later populate the $category_info array.
Hell, yeah, "serendipity_event_categorytemplates" really offers that option,
thank you Garvin!
But things still don't work as expected.
{$category} still showing the 'wrong' category
{$category_info}-array still showing 'wrong' category
The {$entry_category}-array is showing the 'right' info. I will try to somehow combine that with the category-navigation, although at the moment I don't have the slightest clue how to do it.
Re: categories' templating & category as "homepage&
Posted: Fri Feb 15, 2008 3:21 pm
by garvinhicking
Hi!
Hm, I don't realy understand what you mean with "wrong category"?
Is your entry associated with multiple categories, or just one? Only in the case of multiple category assignments you can't really fill $category_info properly...
Regards,
Garvin
Posted: Fri Feb 15, 2008 3:35 pm
by Ramoney
I'll try and explain:
Every entry belongs to only one category, for example:
"entry 1" belongs to "category 2", but both, {$category} and the
{$category_info}-array show "category 1" when viewing "entry 1" in single entry view.
What I would need when viewing "entry 1" in single entry view is:
{$category} having the value "2" (right) instead of "1" (wrong)
That would result in the category-link for "category 2" having the CSS-class "currentpage" and everything would be fine.
Posted: Fri Feb 15, 2008 3:36 pm
by garvinhicking
Hi!
Could it be you're using event plugins like "Start Page category"? This plugin fixates category IDs...
Regards,
Garvin
Posted: Fri Feb 15, 2008 3:52 pm
by Ramoney
garvinhicking wrote:Could it be you're using event plugins like "Start Page category"? This plugin fixates category IDs...
Yes, see topic!
But disabling this event-plugin only results in a slightly different result. Now {$category} is set "false" and the {$category_info}-array is empty.
Still the {$entry_category}-array shows the right values: categoryid => "2"
Posted: Fri Feb 15, 2008 3:56 pm
by garvinhicking
Hi!
Yea, the $entry_* stuff is completely on its own.
$category_info is set in index.php and can only get the right values if $serendipity['GET']['category'] was set prior to that. Actually the categorytemplates plugin should properly set this variable when you use it, so I don't really know why it should not do that. One would need to inspect that plugin and see where it sets this variable and make sure it is set properly and BEFORE index.php actually uses it. This might make a difference if the plugin uses the hook 'genpage' but might need to set it on 'frontend_configure' already.
It might be that you'll need to write your own little event plugin that passes through a category ID and sets the smarty variable $category_info properly.
Regards,
Garvin
Posted: Fri Feb 15, 2008 4:22 pm
by Ramoney
Thank you Garvin for your time and help.
I will see what I can do and will post the result here, if achieved.
Ramoney
Posted: Fri Feb 15, 2008 8:31 pm
by Ramoney
Changing
Code: Select all
{if $plugin_category.categoryid == $category}currentpage{/if}
to
Code: Select all
{if $plugin_category.categoryid == $entry_category.categoryid}currentpage{/if}
in plugin_categories.tpl seems to do what I wanted to achieve.
Well, it does not work in empty categories, but who needs empty categories...?