Hello!
Im new to GS and i was searching some conditional tags! for example IF HOME, or IF INDEX, if page XXXX do this.....
are something similar available?
thanks.
I think i can use template!
you can base on page names (use their slugs), or their parents and serve the content you want
@Live
Insert something like this in your template.php
Code:
<?php
if (return_page_slug()=='index') {
echo 'Hello, this is the index page!';
}
?>
yojoe Wrote:you can base on page names (use their slugs), or their parents and serve the content you want
About checking parents... I hadn't realised there are return_parent() and get_parent() functions... they're not listed in the docs
http://get-simple.info/docs/theme-codex/
look at the functions located in common or theme functions files within admin/inc directory
with slugs and parents you can create conditionals you need.
The problem is with automating it seamlessly, when a user changes page name or create a new one. You could base on a prefix string in page name.
Carlos Wrote:About checking parents... I hadn't realised there are return_parent() and get_parent() functions... they're not listed in the docs http://get-simple.info/docs/theme-codex/
I added these 2 tags to the WIKI, but I ask to add a correct explanation, as I am not so firm in that!
Connie Wrote:I added these 2 tags to the WIKI, but I ask to add a correct explanation, as I am not so firm in that!
This is an old thread and
return_parent() was depreciated for v3.0.
There is phpdoc format help for get_parent() in admin/inc/theme_functions.php:
Code:
/**
* Get Page Parent Slug
*
* This will return the slug value of a particular page's parent
*
* @since 1.0
* @uses $parent
*
* @param bool $echo Optional, default is true. False will 'return' value
* @return string Echos or returns based on param $echo
*/
Thanks, Nick
I took off that one tag and added the explanation to the other one
Thanks!
Connie
Now that the source is all documented with phpdoc comments (V3.0+), it would be really nice to have
phpDocumentor produce something – always up-to-date – for the wiki ...
There's a nice example at,
ahem some other cms site.
hameau Wrote:This is an old thread and return_parent() was depreciated for v3.0.
Question for devs- could depreciated functions please be changed to generate a warning message when site is is in debug mode?
-Rob A>
Version 3.1 Beta r525
Code:
<?php if (get_parent()=='slug'){ ?>
this conditional is not working but this
Code:
<?php if (return_parent()=='slug'){ ?>
works, even it's a depreciated function.
By default get_parent() echoes the parent but does not return it.
The correct way would be:
Code:
<?php if (get_parent(false)=='slug'){ ?>
(BTW I use
0 instead of
false, it's the same)