This should be a simple question and answer...
I know that a basic premise of Drupals theme hierarchy should be that if I want a page for a specific node I make a file page-[type].tpl.php. I have done this and I still get a "Page not found" issue. Creating a node-[type].tpl.php works for overriding the node template for the specific node type.
Does anyone have any suggestions for what might be missing from the out of the box Drupal solution to get this working?
I've tried adding the following function to my template.php which I found on a forum post previously but with no success:
function _phptemplate_variables($hook, $vars) { if ($hook == 'page' && isset($vars['node'])) { $vars['template_files'][] = 'page-'.str_replace('_', '-', $vars['node']->type); } return $vars; }
The page you are trying to create what is creating the URL. Does the URL come from Pathautor or Views?
Thanks,
Steve
Steve Kessler
Denver DataMan
303-587-4428
http://www.denverdataman.com/content/enewsletter-signup Sign up for the Denver DataMan Free eNewsletter
From: Scott Matthews [mailto:smatthews@optaros.com] Sent: Friday, April 10, 2009 6:53 AM To: support@drupal.org Subject: [support] Overriding page.tpl.php for node type...
This should be a simple question and answer...
I know that a basic premise of Drupals theme hierarchy should be that if I want a page for a specific node I make a file page-[type].tpl.php. I have done this and I still get a "Page not found" issue. Creating a node-[type].tpl.php works for overriding the node template for the specific node type.
Does anyone have any suggestions for what might be missing from the out of the box Drupal solution to get this working?
I've tried adding the following function to my template.php which I found on a forum post previously but with no success:
function _phptemplate_variables($hook, $vars) { if ($hook == 'page' && isset($vars['node'])) { $vars['template_files'][] = 'page-'.str_replace('_', '-', $vars['node']->type); } return $vars; }
I'm not sure I understand your question? I'm not using path auto or views. I'm just typing in the URL:
And looking to access the page
Page-type.tpl.php
On 4/10/09 9:13 AM, "Steve Kessler" skessler@denverdataman.com wrote:
The page you are trying to create what is creating the URL. Does the URL come from Pathautor or Views?
Thanks, Steve
Steve Kessler Denver DataMan 303-587-4428 Sign up for the Denver DataMan Free eNewsletter http://www.denverdataman.com/content/enewsletter-signuphttp://www.denverdataman.com/content/enewsletter-signup
From: Scott Matthews [mailto:smatthews@optaros.com] Sent: Friday, April 10, 2009 6:53 AM To: support@drupal.org Subject: [support] Overriding page.tpl.php for node type...
This should be a simple question and answer...
I know that a basic premise of Drupals theme hierarchy should be that if I want a page for a specific node I make a file page-[type].tpl.php. I have done this and I still get a "Page not found" issue. Creating a node-[type].tpl.php works for overriding the node template for the specific node type.
Does anyone have any suggestions for what might be missing from the out of the box Drupal solution to get this working?
I've tried adding the following function to my template.php which I found on a forum post previously but with no success:
function _phptemplate_variables($hook, $vars) { if ($hook == 'page' && isset($vars['node'])) { $vars['template_files'][] = 'page-'.str_replace('_', '-', $vars['node']->type); } return $vars; }
Basically, you should be calling the template file page-node-[url].tpl.php
Take a look at http://drupal.org/node/190815
The override priority for pages looks like this:
1. page-node-edit.tpl.php 2. page-node-1.tpl.php 3. page-node.tpl.php 4. page.tpl.php
Cheers,
blake hall
On Fri, Apr 10, 2009 at 8:24 AM, Scott Matthews smatthews@optaros.comwrote:
I’m not sure I understand your question? I’m not using path auto or views. I’m just typing in the URL:
And looking to access the page
Page-type.tpl.php
On 4/10/09 9:13 AM, "Steve Kessler" skessler@denverdataman.com wrote:
The page you are trying to create what is creating the URL. Does the URL come from Pathautor or Views?
Thanks, Steve
Steve Kessler *Denver DataMan *303-587-4428 Sign up for the Denver DataMan Free eNewsletter http://www.denverdataman.com/content/enewsletter-signuphttp://www.denverdataman.com/content/enewsletter-signup
*From:* Scott Matthews [mailto:smatthews@optaros.com]<smatthews@optaros.com%5D> *Sent:* Friday, April 10, 2009 6:53 AM *To:* support@drupal.org *Subject:* [support] Overriding page.tpl.php for node type...
This should be a simple question and answer...
I know that a basic premise of Drupals theme hierarchy should be that if I want a page for a specific node I make a file page-[*type*].tpl.php. I have done this and I still get a “Page not found” issue. Creating a node-[type].tpl.php works for overriding the node template for the specific node type.
Does anyone have any suggestions for what might be missing from the out of the box Drupal solution to get this working?
I’ve tried adding the following function to my template.php which I found on a forum post previously but with no success:
function _phptemplate_variables($hook, $vars) { if ($hook == 'page' && isset($vars['node'])) { $vars['template_files'][] = 'page-'.str_replace('_', '-', $vars['node']->type); } return $vars; }
-- [ Drupal support list | http://lists.drupal.org/ ]
So you're saying there's no way, out of the box, to have a page template associate with a specific node type?
There's no function that I could write to automatically associate a page template with a specific node type?
Is the only real way to achieve this with a view?
If this is true, that's helpful and I'll just go down that path. I'm just sure I know of people (who are on vacation now) that have made this work.
On 4/10/09 9:33 AM, "Blake Hall" hall.blake@gmail.com wrote:
Basically, you should be calling the template file page-node-[url].tpl.php
Take a look at http://drupal.org/node/190815
The override priority for pages looks like this:
1. page-node-edit.tpl.php 2. page-node-1.tpl.php 3. page-node.tpl.php 4. page.tpl.php
Cheers,
blake hall
On Fri, Apr 10, 2009 at 8:24 AM, Scott Matthews smatthews@optaros.com wrote: I'm not sure I understand your question? I'm not using path auto or views. I'm just typing in the URL:
And looking to access the page
Page-type.tpl.php
On 4/10/09 9:13 AM, "Steve Kessler" skessler@denverdataman.com wrote:
The page you are trying to create what is creating the URL. Does the URL come from Pathautor or Views?
Thanks, Steve
Steve Kessler Denver DataMan 303-587-4428 Sign up for the Denver DataMan Free eNewsletter http://www.denverdataman.com/content/enewsletter-signuphttp://www.denverdataman.com/content/enewsletter-signup
From: Scott Matthews [mailto:smatthews@optaros.com] mailto:smatthews@optaros.com%5Dmailto:smatthews@optaros.com%5D Sent: Friday, April 10, 2009 6:53 AM To: support@drupal.org Subject: [support] Overriding page.tpl.php for node type...
This should be a simple question and answer...
I know that a basic premise of Drupals theme hierarchy should be that if I want a page for a specific node I make a file page-[type].tpl.php. I have done this and I still get a "Page not found" issue. Creating a node-[type].tpl.php works for overriding the node template for the specific node type.
Does anyone have any suggestions for what might be missing from the out of the box Drupal solution to get this working?
I've tried adding the following function to my template.php which I found on a forum post previously but with no success:
function _phptemplate_variables($hook, $vars) { if ($hook == 'page' && isset($vars['node'])) { $vars['template_files'][] = 'page-'.str_replace('_', '-', $vars['node']->type); } return $vars; }
-- [ Drupal support list | http://lists.drupal.org/ ]
You can make node TPL files.
node-node_name.tpl.php
Is that what you are looking for?
-Steve
Steve Kessler
Denver DataMan
303-587-4428
Sign http://www.denverdataman.com/content/enewsletter-signup up for the Denver DataMan Free eNewsletter
From: Scott Matthews [mailto:smatthews@optaros.com] Sent: Friday, April 10, 2009 7:41 AM To: support@drupal.org Subject: Re: [support] Overriding page.tpl.php for node type...
So you're saying there's no way, out of the box, to have a page template associate with a specific node type?
There's no function that I could write to automatically associate a page template with a specific node type?
Is the only real way to achieve this with a view?
If this is true, that's helpful and I'll just go down that path. I'm just sure I know of people (who are on vacation now) that have made this work.
On 4/10/09 9:33 AM, "Blake Hall" hall.blake@gmail.com wrote:
Basically, you should be calling the template file page-node-[url].tpl.php
Take a look at http://drupal.org/node/190815
The override priority for pages looks like this:
1. page-node-edit.tpl.php 2. page-node-1.tpl.php 3. page-node.tpl.php 4. page.tpl.php
Cheers,
blake hall
On Fri, Apr 10, 2009 at 8:24 AM, Scott Matthews smatthews@optaros.com wrote:
I'm not sure I understand your question? I'm not using path auto or views. I'm just typing in the URL:
And looking to access the page
Page-type.tpl.php
On 4/10/09 9:13 AM, "Steve Kessler" skessler@denverdataman.com wrote:
The page you are trying to create what is creating the URL. Does the URL come from Pathautor or Views?
Thanks, Steve
Steve Kessler Denver DataMan 303-587-4428 Sign up for the Denver DataMan Free eNewsletter http://www.denverdataman.com/content/enewsletter-signup http://www.denverdataman.com/content/enewsletter-signup
From: Scott Matthews [mailto:smatthews@optaros.com] mailto:smatthews@optaros.com%5D mailto:smatthews@optaros.com%5D Sent: Friday, April 10, 2009 6:53 AM To: support@drupal.org Subject: [support] Overriding page.tpl.php for node type...
This should be a simple question and answer...
I know that a basic premise of Drupals theme hierarchy should be that if I want a page for a specific node I make a file page-[type].tpl.php. I have done this and I still get a "Page not found" issue. Creating a node-[type].tpl.php works for overriding the node template for the specific node type.
Does anyone have any suggestions for what might be missing from the out of the box Drupal solution to get this working?
I've tried adding the following function to my template.php which I found on a forum post previously but with no success:
function _phptemplate_variables($hook, $vars) { if ($hook == 'page' && isset($vars['node'])) { $vars['template_files'][] = 'page-'.str_replace('_', '-', $vars['node']->type); } return $vars; }
-- [ Drupal support list | http://lists.drupal.org/ ]
On Apr 10, 2009, at 6:24 AM, Scott Matthews wrote:
I’m not sure I understand your question? I’m not using path auto or views. I’m just typing in the URL:
And looking to access the page
Page-type.tpl.php
You need to have a node created in Drupal first, with the path 'type' before you can create a template for the node-type. You can add node types to your site at admin/content/types. Alternately you could create a new node, review the URL when you are done and if it is example.com/node/1, then you could use the template page- node-1.tpl.php for that node.
-Mike
__________________ Michael Prasuhn 503.488.5433 office 714.356.0168 cell 503.661.7574 home mike@mikeyp.net http://mikeyp.net
have you created the content type in you drupal???
So I've received a lot of great suggestions ... I've got one more to try before I can say I've tried them all. It seems I may not have fully explained everything I've done so that everyone is on the same page.
I enabled CCK and created a new content type (call it testtype for example) that I wish to theme.
I created new content for that type so it shows up on my default screen
I created a template node-testtype.tpl.php based on the node.tpl.php and modified that new file to make sure that my testtype was being interpreted by it. It was, so the node template override works.
The difficulty I've still had is creating a page dedicated to that type to show only that type and themed accordingly
* I've created a page page-testtype.tpl.php * I've modified my template.php adding the function "_phptemplate_variables" with suggestions I've found here * Each change was tested after clearing the cache to reset the registry
None of these worked for me. Now based on the online manual, and a reminder by one responder, it seems like this approach SHOULDN't work out of the box ( http://drupal.org/node/190815) but users here, and co-workers, have seen it work so if anyone has any suggestions of what I might be missing do do what I wish to do, I'd appreciate it.
And I wish to say again that I really appreciate all the attempted help that I've received so far!!!
On 4/10/09 11:19 AM, "Michael Prasuhn" mike@mikeyp.net wrote:
On Apr 10, 2009, at 6:24 AM, Scott Matthews wrote:
I'm not sure I understand your question? I'm not using path auto or views. I'm just typing in the URL:
And looking to access the page
Page-type.tpl.php
You need to have a node created in Drupal first, with the path 'type' before you can create a template for the node-type. You can add node types to your site at admin/content/types. Alternately you could create a new node, review the URL when you are done and if it is example.com/node/1, then you could use the template page- node-1.tpl.php for that node.
-Mike
__________________ Michael Prasuhn 503.488.5433 office 714.356.0168 cell 503.661.7574 home mike@mikeyp.net http://mikeyp.net
-- [ Drupal support list | http://lists.drupal.org/ ]
this work for me, in template.tpl.php
function _phptemplate_variables($hook, $vars) { if ($hook == 'page') { if ($vars['node'] && arg(2) != 'edit') { $vars['template_files'][] = 'page-'. $vars['node']->type; } return $vars; }
them , i create some files!
page-blog.tpl.php page-forum.tpl.php page-privatemsg.tpl.php page-my_node.tpl.php
Is there nothing more that you did for this? I just plugged this in replacing the version of that method I had before and it did not work. It's still not recognizing my page-type.tpl.php.
Did you mean to name the file template.tpl.php, or did you mean template.php?
On 4/10/09 9:55 AM, "Aldo Martinez Selleras" aldo@caonao.cu wrote:
this work for me, in template.tpl.php
function _phptemplate_variables($hook, $vars) { if ($hook == 'page') { if ($vars['node'] && arg(2) != 'edit') { $vars['template_files'][] = 'page-'. $vars['node']->type; } return $vars; }
them , i create some files!
page-blog.tpl.php page-forum.tpl.php page-privatemsg.tpl.php page-my_node.tpl.php
-- ---------------------- Aldo Martinez Selleras Especialista en Telematica CITMATEL GND Camaguey Tel: 53 32 291661 Linux User #364356 -- [ Drupal support list | http://lists.drupal.org/ ]
That would be the name of the file. So if you have a node type called blog it would be.
node-blog.tpl.php
Hope this helps.
Thanks,
Steve
Steve Kessler
Denver DataMan
303-587-4428
Sign http://www.denverdataman.com/content/enewsletter-signup up for the Denver DataMan Free eNewsletter
From: Scott Matthews [mailto:smatthews@optaros.com] Sent: Friday, April 10, 2009 8:37 AM To: support@drupal.org Subject: Re: [support] Overriding page.tpl.php for node type...
Is there nothing more that you did for this? I just plugged this in replacing the version of that method I had before and it did not work. It's still not recognizing my page-type.tpl.php.
Did you mean to name the file template.tpl.php, or did you mean template.php?
On 4/10/09 9:55 AM, "Aldo Martinez Selleras" aldo@caonao.cu wrote:
this work for me, in template.tpl.php
function _phptemplate_variables($hook, $vars) { if ($hook == 'page') { if ($vars['node'] && arg(2) != 'edit') { $vars['template_files'][] = 'page-'. $vars['node']->type; } return $vars; }
them , i create some files!
page-blog.tpl.php page-forum.tpl.php page-privatemsg.tpl.php page-my_node.tpl.php
-- ---------------------- Aldo Martinez Selleras Especialista en Telematica CITMATEL GND Camaguey Tel: 53 32 291661 Linux User #364356 -- [ Drupal support list | http://lists.drupal.org/ ]
After you put that in, you need to clear Drupal's cache so that it rebuilds the theme registry (D6+ only).
Jamie Holly http://www.intoxination.net http://www.hollyit.net
Scott Matthews wrote:
Is there nothing more that you did for this? I just plugged this in replacing the version of that method I had before and it did not work. It’s still not recognizing my page-type.tpl.php.
Did you mean to name the file template.tpl.php, or did you mean template.php?
On 4/10/09 9:55 AM, "Aldo Martinez Selleras" aldo@caonao.cu wrote:
this work for me, in template.tpl.php function _phptemplate_variables($hook, $vars) { if ($hook == 'page') { if ($vars['node'] && arg(2) != 'edit') { $vars['template_files'][] = 'page-'. $vars['node']->type; } return $vars; } them , i create some files! page-blog.tpl.php page-forum.tpl.php page-privatemsg.tpl.php page-my_node.tpl.php -- ---------------------- Aldo Martinez Selleras Especialista en Telematica CITMATEL GND Camaguey Tel: 53 32 291661 Linux User #364356 -- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
sorry, it's template.php
i don't do anymore, just this...
look, that was my guide
Different page templates for different content types Description
Once upon a time there was a drupal themer working on a dark and stormy night, he sat there wondering how to make different page templates for certain content types on his site. He thought about how the drupal template system seems to be missing this for some reason... Suddenly, he had a vision! Like a ray of light bringing, hope and happiness down from the heavens!! oh yes!! Resolution
<?php // Add additional template suggestions function _phptemplate_variables($hook, $vars) { switch ($hook) { case 'page': // Add page template suggestions based on node type, if we aren't editing the node. if ($vars['node'] && arg(2) != 'edit') { $vars['template_files'][] = 'page-'. $vars['node']->type; } break; } return $vars; } ?>
This means if you have a content type called event and you want it to have a custom page layout, just copy page.tpl.php to page-event.tpl.php.
got it?
just dump the code into template.php, then make a page template called page-[CONTENT TYPE].tpl.php
and drupal will use that instead
Can this be achieved for node.tpl
Hi,
Can we have different node templates based on the node types. Is this possible in Drupal? Posted by Visitor (not verified) on Thu, 2008-08-21 02:07
As of Drupal 5, just copy your node.tpl.php file to whichever node-CONTENT_TYPE.tpl.php and that template file will be used for theming nodes of that type.
For example, node-event.tpl.php. Posted by Benjamin Melançon on Thu, 2008-08-21 05:41
Could the problem also be that the base template file needs to also exist? For example, in order for node-[content type].tpl.php to work, node.tpl.php must also exist and be in the same directory. Maybe the same goes for page templates?
- John
Aldo Martinez Selleras wrote:
look, that was my guide
Different page templates for different content types Description
Once upon a time there was a drupal themer working on a dark and stormy night, he sat there wondering how to make different page templates for certain content types on his site. He thought about how the drupal template system seems to be missing this for some reason... Suddenly, he had a vision! Like a ray of light bringing, hope and happiness down from the heavens!! oh yes!! Resolution
<?php // Add additional template suggestions function _phptemplate_variables($hook, $vars) { switch ($hook) { case 'page': // Add page template suggestions based on node type, if we aren't editing the node. if ($vars['node'] && arg(2) != 'edit') { $vars['template_files'][] = 'page-'. $vars['node']->type; } break; } return $vars; } ?>
This means if you have a content type called event and you want it to have a custom page layout, just copy page.tpl.php to page-event.tpl.php.
got it?
just dump the code into template.php, then make a page template called page-[CONTENT TYPE].tpl.php
and drupal will use that instead
Can this be achieved for node.tpl
Hi,
Can we have different node templates based on the node types. Is this possible in Drupal? Posted by Visitor (not verified) on Thu, 2008-08-21 02:07
As of Drupal 5, just copy your node.tpl.php file to whichever node-CONTENT_TYPE.tpl.php and that template file will be used for theming nodes of that type.
For example, node-event.tpl.php. Posted by Benjamin Melançon on Thu, 2008-08-21 05:41
Again, I appreciate all the help.
It appears I've been mistaken. It's not that my page-[contenttype].tpl.php isn't being recognized, it's that components on it are not being rendered.
I put some text into the template and I see it show up when I go to http://localhost/contenttype so the page is recognized. But the node is not rendered, nor are other elements that are rendered when I go to http://localhost/node.
I'll probably just have to attempt to debug this further. I just find it weird that these things aren't coming up. I might have to do more work with the pre-process methods.
On 4/10/09 11:46 AM, "John Callahan" john.callahan@UDel.Edu wrote:
Could the problem also be that the base template file needs to also exist? For example, in order for node-[content type].tpl.php to work, node.tpl.php must also exist and be in the same directory. Maybe the same goes for page templates?
- John
Aldo Martinez Selleras wrote:
look, that was my guide
Different page templates for different content types Description
Once upon a time there was a drupal themer working on a dark and stormy night, he sat there wondering how to make different page templates for certain content types on his site. He thought about how the drupal template system seems to be missing this for some reason... Suddenly, he had a vision! Like a ray of light bringing, hope and happiness down from the heavens!! oh yes!! Resolution
<?php // Add additional template suggestions function _phptemplate_variables($hook, $vars) { switch ($hook) { case 'page': // Add page template suggestions based on node type, if we aren't editing the node. if ($vars['node'] && arg(2) != 'edit') { $vars['template_files'][] = 'page-'. $vars['node']->type; } break; } return $vars; } ?>
This means if you have a content type called event and you want it to have a custom page layout, just copy page.tpl.php to page-event.tpl.php.
got it?
just dump the code into template.php, then make a page template called page-[CONTENT TYPE].tpl.php
and drupal will use that instead
Can this be achieved for node.tpl
Hi,
Can we have different node templates based on the node types. Is this possible in Drupal? Posted by Visitor (not verified) on Thu, 2008-08-21 02:07
As of Drupal 5, just copy your node.tpl.php file to whichever node-CONTENT_TYPE.tpl.php and that template file will be used for theming nodes of that type.
For example, node-event.tpl.php. Posted by Benjamin Melançon on Thu, 2008-08-21 05:41
-- [ Drupal support list | http://lists.drupal.org/ ]
It is my understanding that 'out of the box' Drupal does NOT use a template suggestion for page templates based on content type. Page templates are overridden by default for the front page or specific nodes only. Node templates CAN be used per content type by default (node template are not what you're asking about.) Plenty of information on http://drupal.org/node/190815 (as already mentioned in this thread.)
To use a page template per content type, I believe you will need to use a custom function in template.php. The one provided by Aldo seems like it should work. It could be that you need to clear the theme cache (http://drupal.org/node/173880#theme-registry).
Or maybe the function is not being processed. You could simply rename the function (.._preprocess_...) and that may help. Or, rename $vars with $variables. Take a look at these two pages.
http://drupal.org/node/223430 http://drupal.org/node/223440
Sorry I can't be more help with the exact naming to use.
- John
************************************************** John Callahan Geospatial Application Developer Delaware Geological Survey, University of Delaware 227 Academy St, Newark DE 19716-7501 Tel: (302) 831-3584 Email: john.callahan@udel.edu http://www.dgs.udel.edu **************************************************
Scott Matthews wrote:
Is there nothing more that you did for this? I just plugged this in replacing the version of that method I had before and it did not work. It's still not recognizing my page-type.tpl.php.
Did you mean to name the file template.tpl.php, or did you mean template.php?
On 4/10/09 9:55 AM, "Aldo Martinez Selleras" aldo@caonao.cu wrote:
this work for me, in template.tpl.php function _phptemplate_variables($hook, $vars) { if ($hook == 'page') { if ($vars['node'] && arg(2) != 'edit') { $vars['template_files'][] = 'page-'. $vars['node']->type; } return $vars; } them , i create some files! page-blog.tpl.php page-forum.tpl.php page-privatemsg.tpl.php page-my_node.tpl.php -- ---------------------- Aldo Martinez Selleras Especialista en Telematica CITMATEL GND Camaguey Tel: 53 32 291661 Linux User #364356 -- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]