Getting something to only show on the home page

Discussion in 'Programming' started by jg123, Feb 11, 2007.

  1. #1
    On my directory Submit4Backlinks.com I want the top blurb,

    We would like to extend a warm welcome to you while visiting our search engine friendly directory. At Submit4Backlinks.com we have many cost effective options for building backlinks for search engine optimization, search engine marketing and promotion of your website. Increasing traffic and getting better search engine position is the goal of many expert webmasters and we would like to help. If you have any comments or are interested in advertising on our directory please email us with the details. Thanks again for visiting our directory.

    to only show on the home page and not any others, what code do I need to put in there?

    thanks (and whoever can help me gets a free regular listing)!!
     
    jg123, Feb 11, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Hard to say without seeing your code. But you could try something like this.

    
    
    <?php
    
    if (!isset($_GET))
    {
    ?>
    
    Your conetent to show on the main page here
    
    <?php
    }
    ?>
    
    PHP:
     
    nico_swd, Feb 12, 2007 IP
  3. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #3
    or,

    
    if(basename($_SERVER['SCRIPT_NAME']) == "index.php")
    {
    ?>
    Your html here
    <?
    }
    ?>
    
    PHP:
     
    krakjoe, Feb 12, 2007 IP
  4. jg123

    jg123 Notable Member

    Messages:
    6,006
    Likes Received:
    387
    Best Answers:
    0
    Trophy Points:
    295
    #4
    Am I supposed to add in anything here?
    basename($_SERVER['SCRIPT_NAME']) == "./")
     
    jg123, Feb 12, 2007 IP
  5. designcode

    designcode Well-Known Member

    Messages:
    738
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    118
    #5
    Try following code,

    if(basename($_SERVER['SCRIPT_NAME']) == "./" || basename($_SERVER['SCRIPT_NAME']) == "index.php" || basename($_SERVER['SCRIPT_NAME']) == "index.html")
    {
    ?>
    Your html here
    <?
    }
    ?>
    PHP:
     
    designcode, Feb 12, 2007 IP
  6. wenzlerpaul

    wenzlerpaul Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    These codes are correct and will work but may present a problem for those who use dynamic pages, for example, osCommerce uses index.php for categories, homepages and other stuffs, the code above will likely display on all categories, homepages and other pages that are running off the index page. Unless you are using a dynamic page, you can use the script above, else, you might want to assign a trigger on a safe location on your index page, or you can combine the above code, with a $_GET function if you are using variables on your url, so if it is isset and index.php, then the data appears.

    Hope it helps.
     
    wenzlerpaul, Feb 12, 2007 IP
  7. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #7
    I have no idea why I posted ./ as the condition, that' meant to be the name of the page you want to display the html on, and replace the html I wrote with your html and then it'll only display on the page you replace ./ with.

    The format of the url really doesn't matter, they are rewrite rules and $_SERVER['SCRIPT_NAME'] is the name of the script being executed, not affected directly by the url of the page being viewed.
     
    krakjoe, Feb 12, 2007 IP
  8. jg123

    jg123 Notable Member

    Messages:
    6,006
    Likes Received:
    387
    Best Answers:
    0
    Trophy Points:
    295
    #8
    Oh boy, I have a lot to learn. Can anyone look at my page and tell me the exact code?

    thanks
     
    jg123, Feb 12, 2007 IP
  9. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #9
    No, cause we can't see your PHP code. You will have to post it.
     
    nico_swd, Feb 12, 2007 IP
  10. proprod

    proprod Active Member

    Messages:
    216
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    90
    #10
    I took a look at your directory... since you're using phpLD (good man) I can help.

    I'm assuming you have your "blurb" in main.tpl ? If so, wrap the "blurb" code in this:


    main.tpl:
    {if $category.ID eq 0 and not $p and not $qu}
    B l u r b C o n t e n t H e r e
    {/if}
    Code (markup):
     
    proprod, Feb 12, 2007 IP
    jg123 likes this.