We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51382
    • 53 Posts
    Hi,

    I have a couple step by step lists I am trying to make (bootstrap 4, accordions).

    One list has 20 steps and the other has 10. They would both use the same chunk, just each step in each list would have different text and titles (TVs).

    Is there a way to dynamically add the same chunk and its TV placeholders one at a time?

    The long way is easy for me to figure out. Add 20 and 15 chunks with different names to each doc and then fill out their TVs, but I'm sure there is an easier way that someone more advanced than me can understand.

    If I'm not being clear, let me know. I'd also settle for just figuring how to do this in 1 doc and then repeating the process in the other one.

    Andrew

    This question has been answered by BobRay. See the first response.

      • 3749
      • 24,544 Posts
      I'm not exactly clear on what you're trying to do (especially the "fill out their TVs" part).

      But this could possibly do what you want:

      [[!InsertChunks? &chunks=`chunk1,chunk2,chunk6`]]


      <?php
      /* Insert Chunks snippet */
      
      $chunks = $modx->getOption('chunks', scriptProperties, array(), true);
      
      $output = '';
      
      foreach ($chunks as $chunk) {
         $output .= "\n" . $modx->getChunk($chunk);
      }
      
      return $output;
        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
        • 51382
        • 53 Posts
        Thanks Bob. I will play around with that.

        To try and rephrase what I am attempting to achieve, if you have two <ol> in different docs, one with 20 entries and one with 10, is there a way they can share the same chunk and tvs (as placeholders) instead of me having to create 2 chunks and 30 tvs?

        An example interface would allow me to click a button and add a new step, so that I didn't have to create pre-defined templates, chunks, tvs, etc.
        • discuss.answer
          • 3749
          • 24,544 Posts
          I'm still not totally clear on what you're doing, but this possible solution might be the simplest if it works for your use case.

          Change the TV values so they are surrounded with li tags.

          Then put all 20 of the TV tags in one chunk, surrounded by the ol tags, but no li tags.

          On the page that only has 10 TVs the other TVs should disappear (assuming that they're either empty, or not connected).

          This is a violation of typical design principles, since it mixes logic, content, and presentation, but it's simple to implement and may solve the problem.
            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
            • 51382
            • 53 Posts
            Thanks Bob. I'll be working on it this weekend.
              • 3749
              • 24,544 Posts
              Don't thank me until it works. wink
                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