We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13740
    • 86 Posts
    I’m working on a site that will have multiple articles listed, and I want the site manager to have the choice of which one is featured on the front page.
    I want a TV on the front document where the manager can insert the doc ID of the "featured" page, and then pull the title, content & one TV from that doc to insert in the front page.
    How do I do this? I thought about using ditto, but I have to specify the parent ID, not the actual document ID
      • 7231
      • 4,205 Posts
      Ditto works with &documents to select specific documents. For example: [!Ditto? &documents=`1,2,3`!] will return only docs 1, 2, and 3.

      If you use a TV it would look like this: [!Ditto? &documents=`[*tvName*]`!]

      Another solution to accomplish this would be to add a "add to home" TV on every document and use Ditto with to only show the options that are tagged. There is a simple tutorial for this on the Ditto support site.
        [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't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 11206
        • 73 Posts
        use - getTemplateVarOutput

        so i’d do it as follows.

        $page_id = $modx->documentObject['id']; // the id of the page currently being passed.
        $page_tv = $modx->getTemplateVarOutput('*',$page_id,"1"); //  the TV of the page.
        $chosen_page_tv = $modx->getTemplateVarOutput('*',$page_tv['chosen_page_id'],"1"); // where chosen_page_id is the TV for the page to appear on the home page.
        


        then you can access the title, content and tv’s from the $chosen_page_tv array.