简体   繁体   中英

Theming a page template for specific content in Drupal 7

Hi everyone i am new in Drupal 7 and i have tried many options bt i can not get specific result that i wanted. I have a Drupal site which have four template files + page.tpl.php + page--front.tpl.php + page--forum.tpl.php + page--blogs.tpl.php

So the page.tpl.php is used as an inner page where forum is being showed and other staffs are showed but i want a page template different than page.tpl.php file where blogs get visible.

Now the problem is that blog urls are like this http://localhost/drupal/content/test-blog http://localhost/drupal/content/blog-one

Now all the pages are redirecting to page.tpl.php file whereas i want it to be redirect to page--blogs.tpl.php page.

I tried this and it works but i know this is not correct solution.

`function lars_preprocess_page(&$variables, $hook) {

 $alias = drupal_get_path_alias(arg(0) . '/' . arg(1));

 $content_path = substr($alias, 0,7);

 if($content_path == 'content'){
 $variables['theme_hook_suggestions'][] =  'page__blogs';}`

I want to know what will be the correct solution for this kind of problem. Thanks in advance.

Since you are working on template.php, you are on the right track.

The only thing "page" knows about are the path arguments. Nothing is in there to pick-up on node types. You need to help it out.

Please follow https://www.drupal.org/node/1142800#comment-4433994

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM