I want index page to list categories

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
jabeavers
Regular
Posts: 22
Joined: Thu Oct 07, 2010 4:31 pm

I want index page to list categories

Post by jabeavers »

I did not know whether to put this here or on the plugin forum. It seems more like a theme question. I want my index page to display a list of the categories of the blog instead of the entries. I have created a .tpl file called categories.tpl, but index.tpl just has {$CONTENT} and I don't know where that variable gets set. I have looked around this site at the documentation, but it seems so disjointed with no continuity that I can't make heads or tails out of it. Also, some of the links are broken so I can't get to the data... Ugh!

I'm looking in the entries.tpl file but I don't know what to change in there because I can't find what the variables in there are, nor what variables are available to me. It would be nice to have documentation on the variables available with the .tpl files and what they contain. Can someone please help me figure this out? I want to show the categories on the index page. The user can then click on a category and see the entries listed in that category. Also, I would like a different header image for each category page.

Sorry about the rant, I'm just frustrated.
John

site: http://gravley.websiteinprogress.us/blog/
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: I want index page to list categories

Post by garvinhicking »

Hi!

You could edit your content.tpl file and change:

Code: Select all

{$ENTRIES}
to:

Code: Select all

{if $is_startpage}
<!-- I want categories! -->
{serendipity_showPlugin class="serendipity_categories_plugin" side="*"}
{else}
<!-- I want entries -->
{$ENTRIES}
{/if}
So when you're on the startpage, you can show the output of the categories sidebar plugin (within the content area! And note you need the sidebar plugin to be installed). And if you're not on the startpage, the default output is shown ("{else}").

"Startpage" is the page you get shown to by default that has no parameters at all; once you have a parameter like "category X" it will jump to the ELSE-branch.

(I wasn't able to test this, but I think it should work)

HTH,
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/
jabeavers
Regular
Posts: 22
Joined: Thu Oct 07, 2010 4:31 pm

Re: I want index page to list categories

Post by jabeavers »

Thanks. What do you mean by "sidebar plugin"? Isn't the sidebar part of s9y and other plugins add content to it? How do I tell if it is installed, and where do I get it if it is not installed?

John
jabeavers
Regular
Posts: 22
Joined: Thu Oct 07, 2010 4:31 pm

Re: I want index page to list categories

Post by jabeavers »

Ok, I think I understand. Do you mean I need to have serendipity_categories_plugin installed? I do, however, I see no difference in my home page. It is still listing my entries. I played with the code, and it seems like it is only going to the else clause.

John
jabeavers
Regular
Posts: 22
Joined: Thu Oct 07, 2010 4:31 pm

Re: I want index page to list categories

Post by jabeavers »

Ok, changed the $is_startpage to $startpage and it works.

Thanks.
John
jabeavers
Regular
Posts: 22
Joined: Thu Oct 07, 2010 4:31 pm

Re: I want index page to list categories

Post by jabeavers »

Now, how do I tell if I am displaying entries in a category (like I click on a category link from my index page), or if I'm displaying an entry from that category? Also, how can I tell which category it is?

Thanks,
John
jabeavers
Regular
Posts: 22
Joined: Thu Oct 07, 2010 4:31 pm

Re: I want index page to list categories

Post by jabeavers »

Don't worry. I got it all working. I was able to list all the variables available to me by putting some {php} tags in my code and recursively printing the variables in "$this". Then I could see what I could use, and I put what I needed in content.tpl. I was also able to put some code in my header.tpl file to show different text for each category page.

I'm quite pleased and my boss is, too.

Thanks for your help, but I'm most greatful for my troubleshooting skills I have picked up over the years. I only wish I would have thought of them earlier. However, I don't think I would have been able to make heads or tails out of all the variables available to me without your help, too. So thanks and you might see me around here asking more questions later. :)

John
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: I want index page to list categories

Post by garvinhicking »

Hi!

I'm sorry, I was away for the weekend so I didn't get your questions. Glad you worked it out, great detective skills :) :)

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