Posts: 3
Threads: 1
Joined: Nov 2010
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.
Posts: 3
Threads: 1
Joined: Nov 2010
I think i can use template!
Posts: 1,204
Threads: 30
Joined: Jun 2010
you can base on page names (use their slugs), or their parents and serve the content you want
Addons: blue business theme, Online Visitors, Notepad
Posts: 3,491
Threads: 106
Joined: Mar 2010
@Live
Insert something like this in your template.php
Code:
<?php
if (return_page_slug()=='index') {
echo 'Hello, this is the index page!';
}
?>
Posts: 3,491
Threads: 106
Joined: Mar 2010
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/
Posts: 1,204
Threads: 30
Joined: Jun 2010
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.
Addons: blue business theme, Online Visitors, Notepad
Posts: 2,928
Threads: 195
Joined: Feb 2011
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!
Posts: 423
Threads: 15
Joined: Mar 2011
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
*/
--
Nick.
Posts: 2,928
Threads: 195
Joined: Feb 2011
Thanks, Nick
I took off that one tag and added the explanation to the other one
Thanks!
Connie
Posts: 423
Threads: 15
Joined: Mar 2011
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.
--
Nick.
Posts: 290
Threads: 26
Joined: Oct 2010
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>
Posts: 30
Threads: 4
Joined: Aug 2011
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.
Posts: 3,491
Threads: 106
Joined: Mar 2010
2011-08-31, 17:35:06
(This post was last modified: 2011-08-31, 17:35:39 by fotothink.)
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)