We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22840
    • 1,572 Posts
    Hi All,

    I created a if statment so that a price box would show on certain pages, however I have now changed to friendly URL’s and i cant seem to get it to work now.

    The code I was using is below, could someone please help me with what I need to change to get it to work again.

    thanks

    Current code

    <?php
    $id = (int)($_GET['id']);
    if ($id=="3" || $id=="4" || $id=="9" || $id=="10" ||$id=="11" || $id=="12" || $id=="13" || $id=="17" || $id=="18" || $id=="19" || $id=="20" || $id=="21" || $id=="22" || $id=="23" || $id=="24" || $id=="25" || $id=="26" || $id=="27" || $id=="28" || $id=="16")
    {
    echo "<div class=\"price_top\"></div>";
    echo "<div class=\"price_midd\">[*box2*]</div>";
    echo "<div class=\"price_bott\"></div>";
    }
    else
    {
    }
    ?>
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The problem is probably with your original links; when not using friendly URLs your key->value pairs start with & because the index.php?id=xx is using the starting ?, but with friendly URLs there’s no starting ?, so your first key->value pair has to have the ? prefix.

      It’s possible that you just need to refresh the site cache to reset all the links in all the pages.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 11206
        • 73 Posts
        cant you do

        $id = $modx->documentObject['id'];
        
        if ($id=="3" || $id=="4" || $id=="9" || $id=="10" ||$id=="11" || $id=="12" || $id=="13" || $id=="17" || $id=="18" || $id=="19" || $id=="20" || $id=="21" || $id=="22" || $id=="23" || $id=="24" || $id=="25" || $id=="26" || $id=="27" || $id=="28" || $id=="16")
        {
        echo "<div class=\"price_top\"></div>";
        echo "<div class=\"price_midd\">[*box2*]</div>";
        echo "<div class=\"price_bott\"></div>";
        }
        else
        {
        }
        


        that way you’ll be getting the id of the page no matter what the friedly url is set to...