We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26163
    • 43 Posts
    Using Evo 1.0.6

    Is there a snippet which allows the admin to do the following:

    In a resource page display a check box (using TV) which if checked displays the resource's longtitle along with the hyperlink to it in a chunk.

    For example, I would like to have a checkbox while adding a resource which says "List this page as popular". Which if checked displays the resource's longtitle in a chunk in a list, like

    Chunk output:
    <h3>Popular Pages</h3>
    <ul>
    <li><a href="[*id*]">[*longtitle*]</a></li>
    </ul>
    


      • 40447
      • 165 Posts
      I'm not quite certain how you mean this. If your tv checkbox is ticked does the snippet then write id and longtitle into the chunk, and after that the chunk outputs to the browser ?
        • 26163
        • 43 Posts
        Yes you are right. I need to output the checkbox result (if checked then) to the chunk in the browser.
        Quote from: sitecms at Jan 19, 2013, 08:40 AM
        I'm not quite certain how you mean this. If your tv checkbox is ticked does the snippet then write id and longtitle into the chunk, and after that the chunk outputs to the browser ?
          • 40447
          • 165 Posts
          I don't know of any snippet out of the box for this.
          As far as I can see it you are going to need 3 things:
          An eventhandler
          A SystemEvent
          getChunk

          You could try a javascript handler
          function notify () {alert ("clicked");}
           $ ("Button"). On ("click", notify);
          

          Make use of SystemEvent
          OnTVFormRender
          OnTVFormSave
          $modx->invokeEvent("OnTVFormSave",
          array(
          	"mode"	=> "new",
          	"id"	=> $newid
          ));  	
          

          Make use of getChunk
          $chunkOutput = $modx->getChunk("chunkName");
          echo $chunkOutput;
          


          Usefull links
          http://sottwell.pogwatch.com/system-events.html
          http://wiki.modxcms.com/index.php/API:makeUrl
          https://forums.modx.com/thread/80693/populate-chunks-on-event-onwebpageprerender






            • 4172
            • 5,888 Posts
            I think you can use Ditto and its filter-property to get your popular Resources.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 40447
              • 165 Posts
              Your question has been answered there by the user okyanet.
              http://stackoverflow.com/questions/14432702/modx-checkbox-using-tv-to-output-result-in-a-chunk
              All you have to do is adapt the code to your case.
              I would appreciate it, if people would post their answer and mark their question as answered here, in case they found their question answered elsewhere. [ed. note: sitecms last edited this post 13 years, 8 months ago.]