By magico on
Hi "themers"
Is it possible to identify the current "page" somehow in the page.tpl.php?
The objective is to create separated template "pages" where it will be putted different HTML, and also associate different CSS ids.
Thanks in advance,
Fernando Silva
Comments
I've seen $_GET['q'] used
I've seen $_GET['q'] used
Yup, and use arg(1) arg(2)
Yup, and use arg(1) arg(2) etc. to get parameters passed to the page such as node id's.
--
www.bargainspy.co.uk | More Drupal modules
--
Ixis (UK): Drupal support, Drupal hosting.
if you figure it out...
Can you post an example code as how you made it work? Thanks!
---
http://raszl.net
Something like this
Put this function somewhere, so you can access it from page.tpl.php:
This will return "page_main" for the front page, "page_node" for node related pages (e.g. /node/1), "page_taxonomy" for taxonomy pages etc.
You can place the returned value as id in the body tag:
And write according CSS:
arg(1), arg(2) etc contain the Drupal internal non-clean URL. for example given an URL taxonomy/term/5, arg(1) would be "taxonomy", arg(2) "term", and arg(3) "5". arg(4) will be empty.
If you want to be more specific with you pages than in my example, you may evaluate arg(2) and others also.
------------------
Gerd Riesselmann
www.gerd-riesselmann.net
Thanks!
When you say: "Put this function somewhere, so you can access it from page.tpl.php" — where would that be?
---
http://raszl.net
template.php
You can put it in a file called "template.php" within your template directory. This file will be included by phpTemplate.engine automatically if it exists.
See here: http://drupal.org/node/16383 for an example what else can be done with "template.php".
------------------
Gerd Riesselmann
www.gerd-riesselmann.net
Nice!
Thanks everyone!
PHPTemplate could add some of this code to make available a variable called "page_id". But for now I'll use the code in page.tpl.php
Body classes and ID
Hi,
http://drupal.org/node/32077
This code will create a body class and id for every page on your site.
Sunny
www.gleez.com