Hey,
Trying to create a page override but it's not taking. The strange thing is it's working for a view I created. If you go to:
www.kaymerica.com/portfolio - this page is a view page which is using my page--portfolio.tpl.php override. My problem is, if I click on a piece of content there, it refuses to use the same page display.
eg. www.kaymerica.com/portfolio/a2zane
That piece of content is a "portfolio" content type and should use the override that views seems to be finding.
Anyone have any idea what I'm doing wrong?
I've done this a million times but this is my first D7 installation so I'm not sure what I could be doing wrong.
Cheers,
Michael
PS - I clear my cache about 500 times a day. So I know that's not the issue. Cheers....
Comments
This is what works for me: In
This is what works for me:
In my theme folder I have a template.php file with the following code:
Create a file 'page--yourcontenttype.tpl.php' in your templates folder (replace 'yourcontenttype' with something else).
Clear the cache and reload your page.
Good luck!
Thanks for the reply. I've
Thanks for the reply. I've added that code with no success. I think maybe something has happened with the content type. It's strange that my views page uses my custom page template, but when I actually go to a piece of content using that content type, it doesn't work. Not sure what else to do.
Hey... actually this did
Hey... actually this did work. I am an idiot.
idiot?
After I read the above I truly got frustrated. After having searched and tried for a few hours, having found the above solution after about 10 minutes (on several websites) it still didn't work here...
I had tried 'page--' and 'page__', used the same characters for the template filename.
I guess you idiot did something alike ;)
The solution is : the above answer is correct! BUT (watch these characters : ' - ' and ' _ ')
* in the template.php file you write : 'page__' . $variables['node']->type;
* as filename you use "page--contenttypemachinename.tpl.php"
I'm a real idiot
Can't follow the instructions above. My template.php file has a lot of stuff in it. Do I add the code (if yes, where - at the beginning, end or somewhere in the middle?), do I replace the my template.php file with one that just has that code in it?
PS: am now going to try a whole lot of stuff... or search for instructions that compensate for my 'idiotness'.
Finally got there!!
Took two hours to find the simple change required.
I found that this helped: https://drupal.org/node/1089656
Where it says:
Using a Zen Subtheme, all I had to do was to go to the template.php file, find the second instance of "preprocess_page" and delete this line which was the line above it, in its entirety:
/* -- Delete this line if you want to use this functionThen make a copy of node.tpl.php and rename it node--boatlisting.tpl.php (where "boatlisting" was the name of the content type.
Had a slight issue with an underscore in the content type's name (it was originally boat_listing) - I omitted to put in the underscore when I renamed the file, but changed the machine name to boatlisting so that it did not have any special characters. (I have a policy when coding to avoid special characters whenever possible - had used a space and Drupal auto-created an underscore - my bad - but that's another story).
SUCCESS!!
Next job: Styling the variables within the content types!!
switch vars for variables
If this code doesn't work
try this code
for omega 4 the argument is already set for you in the theme_page_preprocess function.
Thx, this helped me
Thx, this helped me
Thanks
Thanks, that's a great solution. Really useful tip.
This works for me
This works for me, need to declare YourTheme_preprocess_page(&$vars, $hook)
Tnx
Tnx
Awesome
Cool, it works
Thank you
Does it work in drupal 8*?
Hi,
Does this function work for drupal 8. Because when I tried adding this function to theme and followed everything until clearing the cache it didn't work. Do you have any idea for me please. I want custom template for content-types. I have followed most of google answers, it looks strange. I might be missing something.
I pretty much know I haven't missed to copy the code from google and naming the file name according and clearing the cache.
Thank you.
custom page template for content type working successfully
step one
---------
create a content type for example: my content type is "fullwidthpage"
step Two
------------
copy page.tpl.php and rename to page--fullwidthpage.tpl in template folder.
step Three
----------------
Add this code to template.php
Don't forgot to change YOUR_THEME_NAME_HERE
Thanks!
Thanks for this - it was really helpful!
avoid this minor gotcha
My theme's template.php file already contained a hook_preprocess_page function so I simply needed to paste the above snippet. However the problem is my function parameter is named "$vars" instead of "$variables", which caused some temporary ("why isn't this working?!") confusion.
Hopefully this will save others a few minutes of time.
Yes, avoid this
Thank you so much! I spent like an hour copying in the various forms of that snippet into hook_preprocess_page function, reloading and clearing the cache, only eventually to read this post and realize that the $variables in the snippet didn't match the $vars in the function definition. Derp.
Html design for content type fields
Hi,
We need to generate a form with html design in drupal 7. The form we created in content type with fields but we don't know to proceed with providing html designs to created fields.
We also tried with adding coding to template.php and overriding concepts but it was not working. Kindly support to proceed if do you have any samples.
Thank you.
Other modules might interfere
Other modules might interfere, for instance "Display suite" which will override any custom templates you're adding in this manner.
You can set the content type to ignore any Display Suite settings by navigating to the "Manage display" section of that particular content type and setting "Select a layout" to "- None -"
This work for me
1)Add this code in your template.php.
2) create page--content_type_name.tpl.php in your template folder.
Note : dont forget to replace content_type_name.
Thank You
This is what works for me:
In my theme folder I have a template.php file with the following code:
Create a file 'page--yourcontenttype.tpl.php' in your templates folder (replace 'yourcontenttype' with something else).
Clear the cache and reload your page.
Good luck!
Not working in Drupal 7 for
Not working in Drupal 7 for some reason.
Keeps using page.tpl.php instead of page--event.tpl.php
Any thoughts of anything else to check?
Not working in Drupal 7 for
I recognise that you have page--event.tpl.php. It is suppose to be page__event.tpl.php.
Either change inside function or change the file name to page__event.tpl.php.
Hope this will help :)