Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display content by page URI?
#1
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
Reply
#2
Sorry, also tried...

Code:
if ( ($theuri =="get_site_url()/", etc
Reply
#3
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.
Reply
#4
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 } ?>
Clients always want to be able to change the content of their pages, but they are unwilling to do so.

Have you ever coded in your underwear before?
Reply
#5
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") )
Reply
#6
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.
}
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#7
^ Zegnat is right.

http://nijikokun.com <- uses that for the next / prev
http://nijikokun.com
random stuff. idk.
Reply




Users browsing this thread: 1 Guest(s)