We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25772
    • 35 Posts
    I’m trying to update my (very old) custom snippets to use chunks with placeholders for output instead of html in the snippet. I’ve run into problems as I need a wrapper for several lines. eg

    <div class="odd">
    <h2>May</h2>
    <p>some date and details</p>
    <p>another date and details</p>
    ...
    </div>

    Then the next month. How do I output to 2 chunks and get the ’dates and details’ chunk inside the month chunk?

    Thanks for any help in advance.

      • 4172
      • 5,888 Posts
      evo?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 25772
        • 35 Posts
        No Revolution.
          • 3749
          • 24,544 Posts
          It sounds like a perfect job for getResourcess, assuming that the docs are located properly in the tree.

          So you’d have one getResources tag in the template that would get the "month" documents and use a simple Tpl Chunk to output any month header text with a placeholder tag for the month name.

          In that Tpl chunk, you’d put another getResources tag to get the month’s events using another Tpl chunk to display each event with placeholders for the event’s various details.

          BTW, getResources will take separate odd and even templates.

            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 25772
            • 35 Posts
            Thanks for your help. Sorry I’ve not answered sooner.

            At the moment the calendar is in an external table of the database (from the time before I was using modx). Maybe now is the time to change this. I’m also trying to link a file to the info (if it exists).
            eg
            <div>
            <h2>month<h2>
            <p>date and link to results file, only if file exists</p>
            etc
            </div>

            The results file name is read from the database table and then I check if it exists. Can I do this with getResources?
            The details files start as xml or html, which are uploaded via a php form that parses the xml, renames it & moves it to its location. I don’t really want to change this as most of the people who upload the results files can barely manage a simple form.

            I have been making good use of your Bob’s Guides - thank you.
              • 3749
              • 24,544 Posts
              I would say that your only option would be a custom snippet. I’m assuming that you’re using MODx Revolution.

              It would check the DB and get the file, then probably set a placeholder with that data -- something like this:


              <?php
              /* GetEventData snippet */
              
              /* get fileName from DB here */
              /* add a path here if necessary */
              if (! empty($filePath)) {
                  $modx->setPlaceholder('event_data',file_get_contents ($filePath));
              }
              return '';


              Then the event data would be displayed wherever you put the placeholder:

              [[!GetEventData]]
              
              [[+event_data]]
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting