Page 1 of 1
Modify Categories?
Posted: Tue Sep 12, 2006 7:19 pm
by DMotel
Is it possible to change the way a category reads when you look at it in the page? What I mean is this: I would like my category to be short when you see it in the nugget, but when you choose one of the pages in the category I would like to make it longer and slightly different.
Is this possible? If so..how?
Re: Modify Categories?
Posted: Tue Sep 12, 2006 7:48 pm
by garvinhicking
Hi!
Yes, you can control this all via templating. You can check the variables documented in the s9y.org techincal documentation (Smarty/CSS Variables) and use $category_info for example to fit your index.tpl or entries.tpl.
Plus you can also use the plugin "Extended options for categories" to put a template on each category and then make independent index/entries.tpl templates for each category.
You can then also check on the $view parameter to see if you are reading a startpage, or a category, or an extended entry page. This variable is only available since serendipity 1.1, but previously you could use other variables like $is_single_entry etc.
HTH,
Garvin
Posted: Tue Sep 12, 2006 7:51 pm
by DMotel
Thanks!
Posted: Tue Sep 12, 2006 9:30 pm
by DMotel
Hmm I see an Events plug-in called "Properties/Templates of categories" but not "Extended options for categories". I downloaded that one but don't see any fields in it that look as though I can modify the page.
Posted: Tue Sep 12, 2006 9:37 pm
by garvinhicking
Hi!
That's the one I mean.
You can then assign a different template to each category; within the templates .tpl files you can then add your Smarty IF/ELSE checks on the variables I mentioned.
This is not the easiest thing to do, so it might take you some time until you get the hang of it. It's a bit like mixing JavaScript and HTML, because you need those IF/ELSE logical constructs.
Best regards,
Garvin
Posted: Tue Sep 12, 2006 10:01 pm
by DMotel
You can then assign a different template to each category;
But the site is already using a template (mt3-gettysburg).
Posted: Wed Sep 13, 2006 10:22 am
by garvinhicking
Hi!
Yes, but you can assign a different template to each category, and thus use independent formattings/layouts using that plugin.
Best regards,
Garvin
Posted: Wed Sep 13, 2006 3:06 pm
by DMotel
so since I want it to look like the rest of the site should I save the general blog template and give it another name and then modify that?
Posted: Wed Sep 13, 2006 5:49 pm
by garvinhicking
Hi!
Yes, I would suggest you to duplicate the current template, and then only make the necessary modifications to the "sub-templates".
Best regards,
Garvin
Posted: Wed Sep 13, 2006 8:43 pm
by DMotel
I'm sorry I am just not getting it. I saved my template with another name but in which file and where exactly would I "hard code" the category name?
Posted: Wed Sep 13, 2006 9:10 pm
by garvinhicking
Hi!
You don't need to hardcode the category name if you use the category-templates plugin to assign a different template for each category. Because then mt-XXX-1/ will be used for your first category, mt-XXX-2 will be used for another category and so forth. You need to assign a specific template to each category to make each category look different.
And you may need to check on the $is_single_entry variable to make a distinction between how to view multiple entries and how to view single entries.
I agree this is not very easy; it involves coding and logic formatting, and the use of Smarty. But that's how it is with customization.
Best regards,
Garvin