We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21112
    • 156 Posts
    This may be something simply done, but I haven’t been able to find documentation or forum discussion on the issue. I want to be able to pull the introtext from one page and display it in another. How is such a thing done? I was guessont maybe something like [[introtext?id=5]] but I have no idea about coding, so that didn’t work smiley Can anyone enlighten me please?

    Thanks!
      • 10487 MODX Staff
      • 1,535 Posts
      Hi neilcreek,

      All you need is the ’introtext’ snippet for your suggestion to work wink

      If you’re pulling from a single page to display on another page, then the following snippet should work:
      /**
      * Snippet: Get info from another page
      *
      */
      
      $id = (isset($id) && is_numeric($id)) ? $id : false;
      $field = (isset($field)) ? $field : false;
      
      if (!$id || !$field) {
       return ''; 
      } else {
       $output = $modx->getPageInfo($id,1,$field);
      }
      
      return $output[$field];


      You can call the snippet like this (assuming you call it ’introtext’):
      [!introtext? &id=`5` &field=`introtext`!]


      You may have guessed, you can use the snippet to pull other content fields ... for example, pagetitle or description. Just set the field parameter to the field you want to retrieve.

      Hope that helps,
      Garry
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 21112
        • 156 Posts
        Brilliant! That worked perfectly! Thank you so much, and thanks also for your quick reply smiley
          • 33337
          • 3,975 Posts
            Zaigham R - MODX Professional | Skype | Email | Twitter

            Digging the interwebs for #MODX gems and bringing it to you. modx.link