We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9207 ☆ A M B ☆
    • 2,475 Posts
    Has anyone written an output filter that separates content into columns? Something like:

    [[*content:columns=`3`]]


    Where 3 is the number of columns you want your content separated into.

    Or perhaps
    [[*content:2columns=`100`]]


    Where 100 is the number of words or characters that should be in each column... but that wouldn’t work all the time if your content had a huge amount of words in it.

    There would have to be a way of defining what HTML tags should be used to separate the columns since output filters don’t allow for more than one parameter.

    Thoughts?
      • 3749
      • 24,544 Posts
      Could you do that with a mini-CSS files and a snippet that injects the proper CSS file with $modx->regClientCss() by checking the &columns property (or the value of a TV)? That would better separate form from content, IMO.
        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
        • 33968
        • 863 Posts
        Quote from: Everett at Aug 09, 2011, 08:40 PM

        There would have to be a way of defining what HTML tags should be used to separate the columns since output filters don’t allow for more than one parameter.
        I guess you could do something like this:
        [[*content:columns=`3|div`]]
        

        columns:
        <?php
        $output = '';
        
        $options = explode('|',$options);
        $cols    = $options[0];
        $tag     = $options[1];
        
        $cols = ... ; // split $input into a $cols part array
        
        foreach ($cols as $col) {
            $output .= '<'.$tag.'>'.$col.'</'.$tag.'>'."\n";
        }
        return $output;
        


        Sorry I was too lazy to work out the code for splitting the input text into columns laugh But if you find a solution, please do post it back here. You’ll obviously need to ensure that words don’t get split down the middle.