We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15175
    • 116 Posts

    I’m following a basic tutorial from the MODx Web Development book (chapter 11), and it’s just not working - could someone have a quick look and tell me why?

    Snippet name: helloworld! (there is actually an error in the book here)

    Snippet code:
    <?php
    $MODx->setPlaceholder("message1", "Hello World!");
    $MODx->setPlaceholder("message2","It is a beautiful day");
    return;
    ?>
    

    Document content:
    [!helloworld!]
    Before Placeholder1 <br>
    [+message1+] <br>
    Before Placeholder2 <br>
    [+message2+]
    

    Should all be pretty simple really, shouldn’t it?

    Please note that the snippet call in the book uses single brackets - I have also tried double brackets. I have also tried using single quotes in place of the double ones.

    I have refreshed page, cleared cache in both MODx and browser.

    Any help would be really appreciated.
      • 4041
      • 788 Posts
      I see a spelling error:

      $MODx should be $modx


      lowercase the $modx and it should work fine smiley

      $modx->setPlaceholder("message1", "Hello World!");
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 7231
        • 4,205 Posts
        $MODx->setPlaceholder
        Should be:
        $modx->setPlaceholder
        $modx is all lowecase. This should fix it smiley
        edit: Breezer beat me to it, but I post anyway wink
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don&#39;t know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 15175
          • 116 Posts
          Great stuff, all working now - thanks very much.