We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37859
    • 34 Posts
    Since recent I'm using MODx and like it very much.
    For a project I'm working on I have the following problem :
    I'm using MODx evolution 1.0.8 and looking for a solution to split the content of [*content*] over two different divs. One div at the top of the main content of the page, and the second div commes later in the main content. (so no pagination !)
    I looked thrue the forum but could not find anything.
    Is this possible in some way ?
    • Could you explain how you'd like this to appear and perhaps why you might not use a Template Variable for the second div? What is the content that will appear at the top and what is the content that will appear lower on the main content? To me these would be two different types of content, a summary and content body or something similar.
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. BlogTwitterLinkedInGitHub
        • 3749
        • 24,544 Posts
        You can use the summary (introtext) field for one of them, or a TV as Jay suggests.

        If you really need to split something and can put a delimiter in between the sections, you could replace the content tag with a snippet tag:

        [[SnippetName? &content=`[[*content*]`]]


        and use a placeholder for each part:

        [+placeholder1+]
        
        <p>Some other stuff </p>
        
        [+placeholder2+]


        Then, in the SnippetName snippet:

        <?php
        $delimiter='###'; // or whatever
        $text = explode($delimiter, $content);
        
        $modx->setPlaceholder('placeholder1', $text[0]);
        $modx->setPlaceholder('placeholder2', $text[1]);
        
        return '';



          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
        • I just create a template variable with a type of rich text and instruct those that have to edit those pages that for one content block on the page you use the content field and for the other, you use the rich text template variable (with a suitable name).
            • 38878
            • 255 Posts
            FWIW, if you want the content to flow dynamically between two elements, CSS can't do that as far as I have found. I do believe that the column element with CSS3 and HTML5 will provide this capability . A good article I found that explains this well is at http://www.adobe.com/devnet/html5/articles/css3-regions.html.

            Maybe not exactly the answer, but maybe relevent to what you're trying to do. Hope it helps.

              • 42562
              • 1,145 Posts
              Splitting one's content without TVs can be awfully useful at times: as in special ads etc.
              But I am curious to know, Bob Ray, how the snippet would recognize the delimiter.
              Is the delimiter placed plainly in between the sections?
              Does the snippet automatically then split the content, [0] being text before the, say, ### and [1], the text after it?
                TinymceWrapper: Complete back/frontend content solution.
                Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
                • 3749
                • 24,544 Posts
                Yes, that's exactly it. Also, neither section will contain the delimiter (though it will show when you edit the page in the Manager). It's a lot handier to use than TVs if you often change your mind about where to split the page.
                  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
                  • 42562
                  • 1,145 Posts
                  Feedback

                  Many thanks Bob Ray. Your snippet and method work like monkey charms, neat and flawless, so far! Well-done.
                  I have been looking for something along this line for too long...a more efficient way than TVs in some areas.

                  Altered syntax for Revo.
                  How I used this to work for me:
                  My chosen delimiter, ###
                  mySplitSnippet
                  <?php
                  $delimiter='###'; // or whatever
                  $text = explode($delimiter, $content);
                   
                  $modx->setPlaceholder('placeholder1', $text[0]);
                  $modx->setPlaceholder('placeholder2', $text[1]);
                   
                  return '';

                  In my site template
                  <html>
                  <body>
                  <div id="content">
                  [[mySplitSnippet? &content=`[[*content]]`]]
                  
                  [[+placeholder1]]
                  
                  [[*myBlogEntryADsInterruptingTV]]
                  [[*mySecondAnnoyingAD-TV]]
                  [[*mythirdCSS-FloatRightAD]]
                  
                  [[+placeholder2]]
                  
                  </div>
                  </body>
                  </html>
                  


                  Then in my Resource
                  Blah blah Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
                  ### irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
                    TinymceWrapper: Complete back/frontend content solution.
                    Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                    5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
                    • 22840
                    • 1,572 Posts
                    @bobby

                    That's a great feature, this could be used to only display the first part on a blog post on the home page and then the full article on the page, a bit like the "more" feature in Wordpress :-0

                    Would love to see this in the core as this could do away with the introtext box ;-)
                      • 3749
                      • 24,544 Posts
                      I'm glad it worked for you. Nice implementation. smiley

                      BTW, if you wanted to have the delimiter invisible to occasionally show the whole page, you could just use:

                      $delimiter = '<!-- split -->';
                        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