GetSimple Support Forum

Full Version: Display content by page URI?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am working on a templaet (yes happy to share when done!), but I have a niggly problem...

I want to be able to display a large picture only on the Home - or front - page i.e. index.php or "/"

Now...in normal php I would use:

Code:
<?php
    $theuri = $_SERVER['REQUEST_URI'];
    if ( ($theuri =="/") or ($theuri =="/index.php")  )
    {
?>

<div id="gallery">
    <div id="top-photo">
        <p>
                <img src="<?php get_theme_url(); ?>/images/img08.jpg" alt="" width="830" height="300" />
            </p>
    </div>
</div>

<?php } ?>

but this doesn't work - no picture is displayed anywhere and no errors - php or otherwise - are displayed.

Help!!!! Smile
Sorry, also tried...

Code:
if ( ($theuri =="get_site_url()/", etc
Tried the follwing:

Code:
<?php
    $theuri = $_SERVER['REQUEST_URI'];
    if ( ($theuri =="/") or ($theuri =="/index.php") )
    {
?>

<div id="gallery">
    <div id="top-photo">
        <p><a href="#"><img src="<?php get_theme_url(); ?>/images/img08.jpg" alt="" width="830" height="300" /></a></p>
    </div>
</div>

<?php } else; { ?>

<h1>Test</h1>

<?php } ?>

And "Test" appears on every page.
Create a flag variable. I used $myhomepage and set it to true.
Put the flag variable at the top of the template for the home page.
For all other pages, just omit the variable or change it to FALSE.

Code:
<?php
    $myhomepage = TRUE;
    if ($myhomepage)
    {
?>

<div id="gallery">
    <div id="top-photo">
        <p>
                <img src="<?php get_theme_url(); ?>/images/screenshot.png" alt="" width="830" height="300" />
            </p>
    </div>
</div>

<?php } ?>
Thanks for the reply - wanted to automate it.

What was wrong was I installed GetSimple away from the root in a directory called GetSimple so

Code:
if ( ($theuri =="/") or ($theuri =="/index.php") )

should've been

Code:
if ( ($theuri =="/GetSimple/") or ($theuri =="/GetSimple/index.php") )
It’s bad to check for the index by path, especially if you want to share your theme. This is a much better way to check:
Code:
if (return_page_slug()=='index') {
   // This is the homepage.
} else {
   // This is a different page.
}
^ Zegnat is right.

http://nijikokun.com <- uses that for the next / prev