By ceci123 on
I have a custom template page called page-news.tpl.php. How do I create new pages for this template?
When I try creating new content ( Admin >> Create content >> Page) it creates a page based on the default page.tpl.php.
Somehow I need to tell Drupal that the new page created must be based on the page-news.tpl.php template.
thanks
C
Comments
Is the template meant to
Is the template meant to display just the one piece of content or different pieces of content?
The template will display
The template will display multiple blocks. I would have thought that creating new pages for my new template page-news.tpl.php was easy just like creating new pages for the default page.tpl.php. Anyway, I don't understand how having one or multiple content would matter.
I must be missing something something...
thanks
Templates are applied to
Templates are applied to existing content, they do not (or at least should not) determine what is show, only how the information is presented.
Blocks go in regions and you can control block visibility from the block configuration page.
The reason for the question about number of pages is will this template be applied to a single page of content or multiple pages of content has to do with a built in features. If you create some content (under create content) and give the content a path of 'news' then it will automatically use the page-news.tpl.php file.
forgive me for I am still
forgive me for I am still learning this system.
To repeat what you said, "If you create some content (under create content) and give the content a path of 'news' then it will automatically use the page-news.tpl.php file".
Wanted to do just that by going to Create content >> Page. But I dont' see where to enter the content path. I only see
Now. Under URL path settings I can uncheck the Automatic alias and enter the "?q=news" but this doesn't work.
Could you explain how to do this? pls. be gentle...one i learn it i won't ask again.
thanks again
c
On the correct path, you
On the correct path, you just want to use "news" (instead of "?q=news").
no luck
I followed your directions and after the page is created it gets created using the DEFAULT page.tpl.php template file.
Believe me, I did it correctly. But for some reason it does not work.
I can see my page-news.tpt.php just find....i just can't seem to be able to create additional pages for the tpl.php file.
thanks again.
C
Opps, forgot you need this:
Opps, forgot you need this: http://drupal.org/node/139766
You will need to add the phptemplate_preprocess_page() function to your template.php (if your theme already as the function you will needto merge the two. (Note you want the Drupal 6 code)
my template.tpl.php now
my template.tpl.php now contains this code:
When I < php print $ messages ;?> to display errors I receive this:
My page-news.tpl.php seems to be working...but I can't seem to be able to create new pages for this page-news.tpl.php theme. It always defaults to page.tpl.php.
Do I need to add some code to the function phptemplate_preprocess_page() above?
I am kind of stuck here.
thanks for your help.
C
This goes back to the
This goes back to the question of how page-news.tpl.php works and when it is used.
As implemented it is aliased based. So pages with aliases like 'news', 'news/somepage', 'news/someotherpage' should end up on page-news.tpl.php while any other page would end up on page.tpl.php (the default).
What path are you using when you get the error (it does not make sense in the context of the code).
got it to work
nevets. Thanks for your explanation(...'news/somepage', 'news/someotherpage') i got it to work.
when creating content I had to create my own alias by unticking the Automatic alias option and write my own alias like this news/newspage1.
Thanks a lot for your help.
C
More than one way to do this...
(I'm reading Leverage Drupal right now, and the phrase "more than one way to do it" keeps popping up.)
If it were me, I'd use the technique shown here:
http://drupal.org/node/249726
It's a little different approach from what you've been doing, but I've used it successfully in the past. It will depend on creating a new content type just for News.
Or you could edit the default page.tpl.php if all of your "pages" are going to be "news." Personally, I wouldn't do it that way. I'd do a new content type.
Hope that gives you some ideas,
Anne
not sure creating content types will make my life easier
Here is the thing. The reason I starter to create "custom templates" is because my homepage, newspage, newsandeventspage, events page is structurely different. Eg. within the body, my newspage has two columns, the eventspage has one two rows with one column, and so on.
Read somewhere about using Panels...but didn't work. I must admit, I haven't worked a lot with content types so who knows this could be my savior.
Do you think I can do all these with content type.
I did read the link(http ://drupal.org/node/249726) you have provided. I could be wrong but it looks like for this to work you still have to create a template file, eg. page-nodetype-news.tpl.php which as stated "would apply to every page that displays a "news" node type."
I am still learning Drupal's behavior and i have learned a lot but seems that there lots more to go.
C
http://drupal.org/project/nod
http://drupal.org/project/node_form_template
You can create a template
You can create a template called 'page-node-add-news.tpl.php' and put your code there so when you create a content of the type 'news' it will automatically open the new template.