2

I am trying to wrap up an HTML theme into a drupal template and I cannot get right idea on how to do this.

I am having a front page, that is unique in it's elements. Then, I am having another page that only keeps the header from the front page, and footer. On this page, I am having some boxes, in witch the content should be nodes. How can I do this?

After that, I am having different pages where I need to add their elements from the admin panel as content. So, there will be more categories, and I need to list the elements from each category into some pages that have different style.

Also, there are regions like footer, where I have some logos ( images ) that again, they need to be nodes and added/edited from the admin panel as content.

Can someone point me to the right direction?

I have tried to create some pages from the admin panel, and tried to use files like page--.tpl.php to have a page in witch I should add nodes/content as the page elements but it is not rendering. Neither if I try lie page--node--.tpl.php or things like that.

I have searched on google for a few hours but I haven't mnaged to get the propper solution.

Thank you in advice!

Best regards, Alex

0

Check out Context module - it will allow you to structure the website based on the node type, URL or other parameters. Depending on this, you can have different blocks displayed, or use different layouts.

See also Display Suite and Panels modules for even more possibilities.

If you want to avoid using additional modules, you can achieve similar functionality through code and preprocess_html or preprocess_page implementations. You can specify special templates that will be selected dynamically, e.g.:

function MYTHEME_preprocess_page(&$variables) {
  // Make sure we are on the single node page.
  if (arg(0) == 'node' && arg(1) && !arg(2)) {
    // This will allow you to have separate page.tpl.php template used only
    // for single nodes. You should have page--single-node.tpl.php file in
    // your theme to see this in action. You can combine this with any
    // additional number of conditions, e.g. node type, user role etc.
    $variables['theme_hook_suggestions'][] = 'page__single_node';
  }
}
  • I like more the preprocess_page solution. But what happens if I am having 5 separate pages with different layout, in witch I want to post content as custom node types? I can target each page theme with a node id for example, but what happens if my client will delete some pages, and re-create them as the new node id's will be changed? This is where I don't understand how to target the theme files from my code, rather than using a plugin – roshkattu Oct 13 '13 at 14:00
  • In that case you need a custom module with an administrative form where your client will select which pages should be used for each section. Or you could do this in theme settings form. Btw you will have this out of the box with Context module - you won't need to touch the code to change nodes. – Aram Boyajyan Oct 13 '13 at 14:02
  • Ok. I will go for Context module and see how it's working. Thank you very much for your explanations sir! – roshkattu Oct 13 '13 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.