[themes] How do i theme blog entries by content type?

brendan, fresh-off.com hello at fresh-off.com
Wed Dec 2 04:56:06 UTC 2009


Thanks for your reply Sebastian!
The Path module had previously been installed, and after reading your post I
installed PathAuto.  But the Theme Developer still isn't giving me any
better candidate file choices.  

For example, I  have a "Services" page, and using PathAuto have it set so
that all the sub pages of "Services" to  automatically come out with nice
URLS (e.g. "services/print").

But I'm still getting candidates like these: 

"page-node-2.tpl.php < page-node.tpl.php < page.tpl.php"   (services)
"page-node-72.tpl.php < page-node.tpl.php < page.tpl.php" (services/print)


from the Theme Developer.  You also said to make sure I am "linking to the
page by its human name"  - not sure what you mean.  Pages are linked to by
human names in my navigation and Path Info,  but its human names I'm hoping
the Theme Developer will give me for candidate files. 


I tried creating a custom content type for all my "Services" pages, but that
doesn't seem to have provided any additional candidates.

Regarding your #2 suggestion - I understand the CSS part, but the Drupal
part is beyond me.  Wouldn't I need a node variable to appear somewhere in
the Body tag, or perhaps a "wrapper" div of some sort to make that work?  

It doesn't seem like maintaining readable naming conventions for complex
themes should be this difficult - there must be some basic concept I'm
missing?  
But I've been working on it all evening and I'm stuck!

Brendan



P.S. - I'll probably try out your theming views suggestion for the blog
entries.  As for Panels, I was hoping to do all the theming "by hand" and
keep the markup as concise as possible - but if it keeps taking this long, I
may have to use the Panels Module.



-----Original Message-----
From: themes-bounces at drupal.org [mailto:themes-bounces at drupal.org] On Behalf
Of sebastian
Sent: Wednesday, November 25, 2009 10:35 AM
To: A list for theme developers
Subject: Re: [themes] How do i theme blog entries by content type?

Hi Brendan,

1. If you are using pathauto, or url names that are more legible than 
node/47 etc. then you should also get better theme template suggestions. 
Make sure that you are linking to the page by its human-name, not its ID 
number.

Some possible other solutions:

2. User devel to find the $node->type variable, and populate that in one 
of your div tags id or class name at a high enough level, that you can 
then detect and then theme just that page (or group of pages by type), 
this would be done in your main page.tpl.php [and then you don't even 
need a separate tpl.php files...]

3. Use Views to make a blog view that you like, and then you can theme 
just that View [with however many 'pages' you make of that view as 
daughters]

4. Use Panels with Views, and then theme on the Panels level.

I'm sure there are others I am forgetting [there is always more than 4 
ways to skin a...]

brendan, fresh-off.com wrote:
> *Hello Themers!*
> 
>  
> 
> */How do I theme a page based on content type?/*
> I've got a site with a few different custom pages and separate .tpl.php 
> files for their custom layouts and CSS/XHTML.  The "Blog" page is a View 
> with a list of teasers.  How do I create a custom .tpl.php file that 
> only targets the "page" (and layout) that the individual/full blog 
> entries are displayed on?
> 
>  
> 
> The Theme Developer list these as the candidate files:  
>  *page-node-#.tpl.php *<* **page-node.tpl.php *<* **page.tpl.php.  *
> 
>  
> 
> But I don't want to use "page.tpl.php" as its too broad in its reach and 
>  I may decide to add other pages non-blog pages in the future. 
> 
>  
> 
> I've tried "page-blog.tpl.php" - but it broke my layout.  I still have 
> some unresolved CSS/XHTML issues, so I'm wondering if 
> "page-blog.tpl.php" is the correct  naming convention, but  I just have 
> a few bugs in my code to work out?
> 
>  
> 
>  
> 
> /A second (less important) question: /
> 
> Keeping track of all those .tpl.php files is getting confusing!  The 
> Views pages are easy ("page-blog.tpl.php"  or "page-work.tpl.php"  for 
> example), but Theme Developer is telling me that for all pages using the 
> "page" content type, that I have to style them by their ID 
> ("page-node-1.tpl.php" for the "about" page).  Is there any way to name 
> a .tpl.php file for a page content type in a more semantic/meaningful way?

> 
>  
> 
> Such as "page-contact.tpl.php" instead of "page-node-392.tpl.php"
> 
>  
> 
>  
> 
> Thanks!
> 
>  
> 
>  
> 
>  
> 
>  
> 
> *brendan, fresh-off.com*
> 
> Creative Direction & Consultation: Web | Print | Brand
> 
>  
> 
> http://fresh-off.com
> 
> hello at fresh-off.com <mailto:hello at fresh-off.com>
> 
> 206.328.1067
> 
>  
> 
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> themes mailing list
> themes at drupal.org
> http://lists.drupal.org/mailman/listinfo/themes
_______________________________________________
themes mailing list
themes at drupal.org
http://lists.drupal.org/mailman/listinfo/themes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/themes/attachments/20091201/35259e9f/attachment-0001.html 


More information about the themes mailing list