Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If template-name == 'xyz' echo ... possible? (conditional by template)
#1
I'm hacking on my template and use includes (header, footer, etc.).
In the header or some includes I sometimes would like to include a conditional asking for the template used actually. For example to include additional js/css for a certain template in the header.inc file. This to avoid creating additional inc files that differ only in one line/part of the code.
In the Forum I found some about doing simliar conditionals with the page_slug (Noindex, nofollow for single page, Display components in specific page only), but not for specific template only.

Is it in some way possible to make a conditional by the used template without a plugin?
Advanced HTML5 & CSS3 coder. Simple JS & PHP hacker (not enough for new function coding). Build one webpage with GS (late 2012). Focusing on Theme customizing/Template files. Experience with WP.
Reply
#2
this was written for components, but will work the exact same way:

http://get-simple.info/wiki/components-d...n-the_page
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Reply
#3
@ChriS
Code:
<?php if ($template_file == 'name-of-template.php') {
...

If used in a component, first do:
Code:
global $template_file;
Reply
#4
@ccagle8: thank you for showing me the possibilities.

@Carlos: Perfect! That was right the code I was looking for. Works now in my template includes... ;-)
Advanced HTML5 & CSS3 coder. Simple JS & PHP hacker (not enough for new function coding). Build one webpage with GS (late 2012). Focusing on Theme customizing/Template files. Experience with WP.
Reply




Users browsing this thread: 1 Guest(s)