We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8384
    • 55 Posts
    One page - two ditto calls. Call at the top of the page needs to be just a list of the entries with a link to the fuller entry further down the page.

    The code I’m using at the top of the page calls the tv ’eventName’ and sorts by date:

    [!Ditto? &filter=`eventName,,2` &sortBy=`eventStartDate` &sortDir=`ASC`!]


    the result is:

    "Title of Entry (eventName)
    by Default admin account on 20-Jul-10 17:41"

    How do I
    1) get rid of "by Default..."
    2) get rid of "on 20-..."
    3) link to the entry further down the page?

    I haven’t had much luck trying to figure out the coding so that’s why I’m here! I tried using &tag and also playing around with phx calls a bit. But no success... huh

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Use a custom chunk tpl with the HTML structure and Ditto placeholders for the output you want. The default Ditto tpl is in the language file (assets/snippets/ditto/lang)
      $_lang['default_template'] = <<<TPL
      
          <div class="ditto_item" id="ditto_item_[+id+]">
              <h3 class="ditto_pageTitle"><a href="[~[+id+]~]">[+pagetitle+]</a></h3>
              <div class="ditto_documentInfo">by <strong>[+author+]</strong> on [+date+]</div>
              <div class="ditto_introText">[+introtext+]</div>
          </div>
      
      TPL;
      

      You can copy/paste this into a chunk, then in your Ditto snippet use &tpl=`chunk-name`. Nothing should change. Then start editing the chunk, checking frequently to make sure you don’t break anything, until you have what you want.
        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
        • 8384
        • 55 Posts
        Thank you!!!!

        Your suggestion led to the solution for the listings. I just created a new chunk, added the &tpl of that new chunk in the ditto call, but I didn’t use the Lang code, just straight html in the chunk.

        Now I’m figuring out how to link from the list to the full entry further down the page. anchor tags are giving me a little trouble at the mo.
          • 29019 ☆ A M B ☆
          • 104 Posts
          Your anchor tags can use a different chunk that’s as simple as:

          <li><a href="#[+alias+]" title="[+longtitle+]">[+menutitle+]</a></li>


          ... just make sure your content chunk has an anchor or id with the alias. If you aren’t using friendly urls or you have duplicate aliases, you could always use the id instead.
            www.darkstardesign.com

            Are you in the Nashville area? Join us for our next MODX meetup!
            • 22427
            • 793 Posts
            This worked well for me:

            First Ditto call:
            <ul>
            [!Ditto? parents=`[*id*]` &sortBy=`menuindex` &sortDir=`DESC` &tpl=`anchorTpl` &display=`99`!]
            </ul>

            where the anchorTpl is
            <li><a href="[~[*id*]~]#a[+id+]">[+menutitle+]</a></li>


            Second Ditto call:
            [!Ditto? parents=`[*id*]` &sortBy=`menuindex` &sortDir=`DESC` &tpl=`articleTpl` &display=`99`!]

            with this articleTpl:
            <a id="a[+id+]"></a>
            <h2> [+menutitle+] </h2>
            [+content+]

              • 8384
              • 55 Posts
              Swepsi - thanks for your answer, I had been trying for the last hour, but it didn’t work for me - I’m sure it’s something to do with how I have things set up and my brain!

              Ottogal - WHOOP! WHOOP! WHOOP! thank you laugh. It worked. This code especially:

              [~[*id*]~]#a[+id+]


              and the placement of the parent id in the ditto calls really helped to make it click on accessing id’s called within the parent id on a page.

              Thank you to all for your help!!!