Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Conditional tags
#1
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.
Reply
#2
I think i can use template! Smile
Reply
#3
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
Reply
#4
@Live

Insert something like this in your template.php

Code:
<?php
if (return_page_slug()=='index') {
  echo 'Hello, this is the index page!';
}
?>
Reply
#5
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/
Reply
#6
look at the functions located in common or theme functions files within admin/inc directory Wink

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
Reply
#7
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!
|--

Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#8
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.
Reply
#9
Thanks, Nick

I took off that one tag and added the explanation to the other one

Thanks!

Connie
|--

Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#10
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.
Reply
#11
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>
Reply
#12
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.
Reply
#13
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)
Reply




Users browsing this thread: 1 Guest(s)