GetSimple Support Forum

Full Version: Condition to home page (index)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hello,

I'm creating a theme which precio that the file template.php has a condition that appears only on the home page (index.php). Can anyone help me what command to use if?

The condition is for some includes, the pages that will create the CMS.

Thanks
Code:
<?php
if (return_page_slug()=='index') {
// your code here ...
}
?>
Carlos Wrote:
Code:
<?php
if (return_page_slug()=='index') {
// your code here ...
}
?>


Ok. Thanks Carlos.

I put the proposed code for you but could not, within the content of the condition is not rendering.

my code looks like this:
Code:
<?php
    if (return_page_slug()=='index') {
        <div class="coda-slider preload" id="coda-slider-1">

             <?php include("index.php");?>

          <?php include("index.php?id=page2");?>

          <?php include("index.php?id=page3");?>
    }
    else {
      get_page_content();
    }
    ?>

Any other tips to make it work?
alvares Wrote:
Carlos Wrote:
Code:
<?php
if (return_page_slug()=='index') {
// your code here ...
}
?>


Ok. Thanks Carlos.

I put the proposed code for you but could not, within the content of the condition is not rendering.

my code looks like this:
Code:
<?php
    if (return_page_slug()=='index') {
        <div class="coda-slider preload" id="coda-slider-1">

             <?php include("index.php");?>

          <?php include("index.php?id=page2");?>

          <?php include("index.php?id=page3");?>
    }
    else {
      get_page_content();
    }
    ?>

Any other tips to make it work?


try like this :

Code:
<?php
    if (return_page_slug()=='index') {
        echo '<div class="coda-slider preload" id="coda-slider-1">';

          include("index.php");

          include("index.php?id=page2");

          include("index.php?id=page3");
    }
    else {
      get_page_content();
    }
    ?>
Excuse me,
my code actually looks like this:
Code:
<div class="coda-slider preload" id="coda-slider-1">
<?php
    if (return_page_slug()=='index') {
          include("index.php");
          include("index.php?id=page2");
          include("index.php?id=page3");
    }
    else {
      get_page_content();
    }
    ?>
</div>

Note that I want to do is to include unique content only for home.
As there is no way to put the includes in the content of dynamic pages, I need them in template.php
Instead of using include, that inserts the whole rendered page in your current page (BTW that might do an infinite loop) you should use some function that inserts only pages' contents.

There are some examples in the forum, also some plugins like SimplePageContent, I18N and others. (In GS 3.1 - beta right now- there's the getPageContent() function)