We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I’m pretty sure I’ve overcomplicated what I’m trying to do here, but at this point, I feel like I’m just chasing my tail and need someone to point out my mistake. Here goes:

    First, some backstory. I have a page that displays a list of press releases in PDF format (title, link to a PDF and date published). It is being populated using Ditto, and I’m pulling in content from sub-documents. Each press release is contained in its own document. The title is being pulled from the longtitle field and the date is the pubdate, and the link is actually a TV called "release-upload," which is set as a "File" and allows the user to upload a PDF (keep this TV in mind; it has to do with the problem I’ll mention at the end). Everything related to this section I just described is working fine.

    Now, here’s my problem. I also want to display on the site’s homepage the titles and links (to the PDFs) of the 10 newest press releases, and I plan to do this using Ditto. However, the client wants the ability to "uncheck" a check box on the individual press release page. Doing so would have no affect on the press release list page I mentioned earlier, but it would keep it from showing up on the homepage.

    So, here’s what I’ve done to make this (mostly) work. On the homepage, I make this Ditto call:

    [!Ditto? &parents=`35` &display=`10` &orderBy=`createdon DESC` &tpl=`pressrelease-tpl`!]


    That template chunk (pressrelease-tpl) contains a reference to this template variable:

    [+pressrelease-toggle+]


    That template variable (pressrelease-toggle) is set up as a Check Box, and has template access from the homepage template and the individual press release page template. Under Input Option Values, it has:

    Yes=={{home-headlines}}


    So, if the checkbox is checked, it loads the home-headlines chunk, which looks like this:

    <li>
            <a href="[+release-upload+]" rel="external">[+pagetitle+]</a>
    </li>


    You’ll notice that [+release-upload+] is the TV that I mentioned earlier. It’s attached to the individual press release page, which allows you to upload a PDF. Now, here’s the weird part: on the homepage, this method actually works fine for the page title, but [+release-upload+] isn’t generating anything.

    What’s going wrong here? It seems like I should easily be able to grab this TV’s value, but it isn’t working. It does work fine on the press release page, which is what’s blowing my mind. Any suggestions on how I can fix this method I used, or possibly suggest an easier method? I’m only so-so with raw php/writing my own snippets/accessing the API, so if you do have a solution that relies on those methods, I’d appreciate as much of a walk-through as possible.

    Thanks, everyone!
      • 17883
      • 1,039 Posts
      I think Ditto`s filters are your friend ;-)

      Leave the checkbox pressrelease-toggle, but change the option in simply

      yes


      Standard:

      no


      (or vice versa).

      Change your Ditto call:
      [!Ditto? &parents=`35` &display=`10` &orderBy=`createdon DESC` &filter=`pressrelease-toggle,yes,1` &tpl=`pressrelease-tpl`!]


      That`s all. Ditto looks if the TV pressrelease-toggle is not eqal "yes" and then filters these docs. The rest is displayed. Easy as that ;-)

      • Can you clarify what goes in the pressrelease-toggle TV? I think I see what the filters do, but I’m having trouble understanding how you suggested I set up the TV.
          • 17883
          • 1,039 Posts
          Can you clarify what goes in the pressrelease-toggle TV?

          TV pressrelease-toggle:
          Type: checkbox
          Options: yes
          Standard: no

          Means a checkbox is displayed, if checked it`s value is "yes". If not/unchecked it is "no". "no" is not really needed, but it is clearer.
          • I’m sorry, but this still isn’t clicking. My Ditto call now looks like this:

            [!Ditto? &parents=`35` &display=`11` &orderBy=`createdon DESC` &filter=`pressrelease-toggle,yes,1` &tpl=`pressrelease-tpl`!]


            For the pressrelease-toggle TV, I have the attached screenshot. No matter what I do, though, the homepage now just displays the word "yes" where my ditto content should be. Also, on that screenshot, I don’t understand where Options or Standard go (I don’t have a Standard field). I’m obviously not understanding something basic here.

            http://www.bluevalleyk12schools.org/screen.jpg

            Thanks for your help. I appreciate it.
              • 17883
              • 1,039 Posts
              "Input Options Values" should only be:

              yes


              "Default Value" should be:

              no


              Sorry for not being clear, I only know the german labels ;-)
              • Thanks, and sorry for the language confusion! I did as you said with yes in "Input Options Values" and no in "Default Value". However, on the homepage, all I get is the word "yes". Any idea why?
                  • 17883
                  • 1,039 Posts
                  Well, your pressrelease-tpl should look like this:

                  <li>
                          <a href="[+release-upload+]" rel="external">[+pagetitle+]</a>
                  </li>
                  • Ohhhhhhhhhhhh...now I get it! It’s working great now. Thank you SO much!!! It wasn’t clicking with me how the TV could get to my extra, unnecessary level of chunks, but now I see that I don’t need it -- I just needed to use the filtering method and not use the extra level to begin with.

                    Thanks so much for your help. You cleared up something that had been confusing me for hours!
                      • 17883
                      • 1,039 Posts
                      It is MODx.. ;-) There are always a lot of approaches. Even your solution would be possible, but with a bit unnecessary overhead.