We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26163
    • 43 Posts
    I am using modx evo to manage events. In ditto, when there is no events, i have called &noResults=`No events yet. to display that there are no events. And below that I have something called "View All" button. Is there any way to hide "View All" button when there is no events?

    Regards,

    Santosh
      • 26163
      • 43 Posts
      Anyone for help please...
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Use &tplLast and put the button’s HTML code in that chunk tpl following the Ditto item’s usual output. Use CSS to display and position the button as you wish.
          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
          • 26163
          • 43 Posts
          Hello,

          Did as you suggested, but here is the problem I encountered.

          I have to show the ditto using following list items:
          <ul>
          <li>Item 1</li>
          <li>Item 2</li>
          <li>Item 3</li>
          <li>Item 4</li>
          </ul>
          <p>View All</p>
          


          I am using the following ditto call:
          [!Ditto? &parents=`38` &orderBy=`createdon DESC` &display=`5` &total=`5` &tpl=`mytpl` &tplFirst=`firsttpl` &tplLast=`lasttpl` &noResults=`No events yet.`!]


          Following are the templates:
          mytpl:
          <li><a href="[~[+id+]~]">[+pagetitle+]</a></li>


          firsttpl:
          <ul>
          <li><a href="[~[+id+]~]">[+pagetitle+]</a></li>


          lasttpl:
          <li><a href="[~[+id+]~]">[+pagetitle+]</a></li>
          </ul>
          <p><a href="[~38~]">View All</a></p>


          Now the problem is if I have more than 3 items, this works good. But If I have only 1 item, it uses the lasttpl eliminating the opening <ul>.

          How do I sort this out?
            • 26163
            • 43 Posts
            OK I have overcome this by doing the following:

            <ul>
            [!Ditto? &parents=`38` &orderBy=`createdon DESC` &display=`5` &total=`5` &tpl=`mytpl` &tplLast=`lasttpl` &noResults=`<li>No events yet.</li></ul>`!]


            mytpl:
            <li><a href="[~[+id+]~]">[+pagetitle+]</a></li>


            lasttpl:
            <li><a href="[~[+id+]~]">[+pagetitle+]</a></li>
            </ul>
            <p><a href="[~38~]">View All</a></p>


            But I have to essentially put the &noResults in li too. Is there any way I put that in paragraph or single line text?
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Why? &noResults is what gets displayed if there are no results. It has nothing to do with the tpls that are applied to list items because there aren’t any.
                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