2 posts / 0 new
Last post
Ton Haarmans
Offline
Last seen: 2 years 1 month ago
Joined: 02/16/2016
how do I create custom layout for content-type page

Hi, I would like to create a custom layout for a custom content-type, for instance the content type 'klantpagina'. In 'normal' Drupal I would add a function to template.php like this:

function platon_preprocess_page(&$variables, $hook) { $alias = drupal_get_path_alias($_GET['q']); if ($alias != $_GET['q']) { $template_filename = 'page'; //Break it down for each piece of the alias path foreach (explode('/', $alias) as $path_part) { // Added the str_replace becayse path parts with - were not being picked up properly by the theme_hook_suggestions $template_filename = $template_filename . '' . str_replace("-", "_", $path_part); $variables['theme_hook_suggestions'][] = $template_filename; } } if (isset($variables['node'])) { $variables['theme_hook_suggestions'][] = 'page__type'. $variables['node']->type; $variables['theme_hook_suggestions'][] = "page__node__" . $variables['node']->nid; } }

how would I do this in Opigno? BTW, I am NOT a PHP-programmer, I just used this piece of code I found somewhere...

James Aparicio
James Aparicio's picture
Offline
Last seen: 1 week 3 days ago
Staff
Joined: 10/30/2013
Hi Ton,
Hi Ton,
 
If you want to just change the interior part of page (the info that is in the content type ),  the only thing you have to do is to add a template  named node-[type].tpl.php in your theme templates folder.
 
 
If you want to display a diferent complete page you do something like you wrote. The opigno theme (platon) only has 1 page template, (page.tpl.php) so if that code is working,  you just have to add a name corresponding to that naming suggestion in the code.
 
There is the html template, then the page template, and then the node template.
 
There is nothing different from Opigno to drupal in that regard.
 
I suggest you take a look at a guide like:
 
 
Dont forget to clear the cahe each new hook/file you add, otherwise it will not be recongnized until you do.