Are "category" headers possible?

Are "category" headers possible?

Postby G. Noel Gross on Sat Feb 24, 2007 2:57 am

I'd like to have an image or additional text describing specific categories.

How would I do that? Right now, text-only category names just appear at the top of the first column of the standard template. :(

Image
G. Noel Gross
 
Posts: 31
Joined: Sat Feb 24, 2007 2:33 am

Postby poolie on Sat Feb 24, 2007 5:36 am

well, you could take the text-only tag and use that as image path.
example

$category shows "YOURCategory"

you would do that: <img src="/bla/$category.gif" width="" height="" alt="" />

and that should do it.
the wiki loves you, the api is your friend.
kulando Blog Hosting.
poolie
 
Posts: 157
Joined: Sat Apr 16, 2005 4:44 pm
Location: Germany

Postby G. Noel Gross on Sat Feb 24, 2007 12:49 pm

Cool. I'll tinker with that.

Seems like an independent "category" template would give me more flexibility, though.
G. Noel Gross
 
Posts: 31
Joined: Sat Feb 24, 2007 2:33 am

Postby phunkphorce on Sat Feb 24, 2007 1:47 pm

1) Create a file called category.template in your templates/standard/ folder.
2) Edit templates/standard/header.template and add the following code wherever you want this category stuff to appear:

Code: Select all
{include file="$blogtemplatepath/category.template")}


3) fill in the contents of category.template with whatever you want.

That's it! You just added your own category template to your site.
phunkphorce
Lifetype Expert
 
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Postby G. Noel Gross on Sat Feb 24, 2007 3:07 pm

Oh, wow. That's great! Almost got it.

How would I limit the display of "category.template" to only pages with "news" category attributes?

I assume I'd have to make a "category.template" for each category I'd like to have a unique header, but I don't have the programming smarts to connect the dots.

Y'all are great! THANK YOU SO MUCH!
G. Noel Gross
 
Posts: 31
Joined: Sat Feb 24, 2007 2:33 am

Postby jondaley on Sun Feb 25, 2007 8:50 am

Hrm. I thought there was a $category object, but I don't see it on the wiki page:
http://wiki.lifetype.net/index.php/Template_Development

You shouldn't need to create multiple template files, but just look at a variable and decide what category you are displaying, and then display different things based on the category.

something like {if $category=="News"} asdad {/if}
but maybe it was removed, or I am making things up about that variable existing.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Postby phunkphorce on Sun Feb 25, 2007 9:24 am

The $category object exists whenever we're browsing a category, it's just that we haven't updated the wiki yet :)

So all you have to do is:

Code: Select all
{if $category}
  currently browing category: {$category->getName()}
{/if}


You should replace the bits between {if..}...{/if} with your own stuff, and use {$category->getName()} to get the textual name of the category.
phunkphorce
Lifetype Expert
 
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Postby G. Noel Gross on Sun Feb 25, 2007 1:27 pm

Thanks, guys. Took some dancing around between your posts, but my feeble brain stumbled upon this ... which WORKS ... eureka!!!

Code: Select all
{if $category->getName()=="Podcast"}
      {include file="$blogtemplate/category.template"}
{/if}
G. Noel Gross
 
Posts: 31
Joined: Sat Feb 24, 2007 2:33 am

Postby G. Noel Gross on Sun Feb 25, 2007 1:35 pm

Argh! Spoke too soon. Now my front page crapped out.

Unfortunately, I learn by effing up. ;)
G. Noel Gross
 
Posts: 31
Joined: Sat Feb 24, 2007 2:33 am

Postby phunkphorce on Sun Feb 25, 2007 2:22 pm

Before you can call $category->getName(), you need to make sure that the $category object actually exists:

Code: Select all
{if $category}
  {if $category->getName() == "..."}
    ...
  {/if}
{/if}
phunkphorce
Lifetype Expert
 
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Postby G. Noel Gross on Sun Feb 25, 2007 4:50 pm

Got it. Now, is there a way to have a unique header on my front page, but no where else? I tried this ...

Code: Select all
{if $OnMainPage}

{include file="$blogtemplate/front.template"}

{/if}


{if $category}
{if $category->getName()=="Podcast"}
{include file="$blogtemplate/podcast.template"}
{/if}
{if $category->getName()=="News"}
{include file="$blogtemplate/news.template"}
{/if}
{/if}
G. Noel Gross
 
Posts: 31
Joined: Sat Feb 24, 2007 2:33 am

Postby phunkphorce on Sun Feb 25, 2007 5:24 pm

main.template is your main page, whatever you include in there will be only shown in the main page. If you want show the message whenever we're not browsing a category, then you need {if $category}...{/if}.
phunkphorce
Lifetype Expert
 
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Postby G. Noel Gross on Sun Feb 25, 2007 6:38 pm

Hmmm.

If I put a JPG on "main.template" it appears on "category" pages too.

I'm just using "category.template" to include a JPG that only appears on category pages.

I'm looking to do the same thing on the "main" page. (Have a unique "include" that only appears on that page.)


I tried adding the "content" of the "main.template" into the new "category" template as well, but it doubled up on everything.

I really appreciate everyone's patience.
G. Noel Gross
 
Posts: 31
Joined: Sat Feb 24, 2007 2:33 am

Postby G. Noel Gross on Mon Feb 26, 2007 10:59 am

Ah-ha! This got me what I was looking for ...

Code: Select all
{if $category}
{if $category->getName()=="Podcast"}
{include file="$blogtemplate/podcast.template"}
{/if}
{if $category->getName()=="News"}
{include file="$blogtemplate/news.template"}
{/if}

{else}

{include file="$blogtemplate/front.template"}
{/if}


See! Y'all learned me. ;)

Now on to how to make "front.template" appeare only on page "1" of my blog. ???
G. Noel Gross
 
Posts: 31
Joined: Sat Feb 24, 2007 2:33 am

Postby G. Noel Gross on Tue Mar 13, 2007 5:30 pm

G. Noel Gross wrote:Now on to how to make "front.template" appear only on page "1" of my blog. ???


Another work around would be to replace these linkages with one of my choosing. Which file would I need to monkey with? Not spotting anything in "main.template" ...

Image
G. Noel Gross
 
Posts: 31
Joined: Sat Feb 24, 2007 2:33 am

Next

Return to Templates

cron