We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 436 ☆ A M B ☆
    • 265 Posts
    A simple design, where one column is a different width than the other yet pulling in content from the same sources, yet sometimes with complex development problems.

    I’ve come across jQuery plugins such as Columnizer but I don’t think its the best solution, and ideally I’d like to use something MODX native.

    I’ve tried a few ideas using the &offset parameter on two getResources calls; for example, the left-hand column with an offset of zero and the right-hand column with an offset of three - but then the pagination doesn’t always work as expected.

    Does anyone have any good ideas for creating a multi-column layout?
      MODX Ambassador for Thailand. Managing Director at Monogon, a web design and development studio based in Bangkok, Thailand. - Follow me on Twitter.
      • 26016
      • 561 Posts
      Hi,
      An interesting question. When I need multiple columns, I’ve just used TV’s and several DIV’s styled to the right sizes and shapes. I’ve also used Ditto calls, and I think GetResources could do the same thing.

      Come to think of it, I think you could template GetResources in such a way that it would produce multi-columns even with one chunk of data(?).

      But as soon as you said pagination, I said, "oh oh"! smiley

      Let’s see what people say.
      Cheers
        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 436 ☆ A M B ☆
        • 265 Posts
        I came up with quite a nice solution today, although I’m not sure if its the simplest method of achieving this:



        <div class="grid_6">
        [[!getPage? &element=`getResources` &parents=`3,4,5,6` &limit=`6` &pageLimit=`2` &tpl=`article.template.first` &tpl_4=`article.template.second` &tpl_5=`article.template.second` &tpl_6=`article.template.second` &includeContent=`1` &toSeparatePlaceholders=`column`]]
        [[!+column0]]
        [[!+column1]]
        [[!+column2]]
        </div>
        
        <div class="grid_3">
        [[!+column3]]
        [[!+column4]]
        [[!+column5]]
        
        <div class="pageNav">[[!+page.nav]]</div>
        </div>


        The article.template.first template is for the left-hand column, and the tpl_4, tpl_5 and tpl_6 article.template.second are for the three articles in the second column - where in the article.template.second template I’ve only included the introduction text and the article.template.first template has the introduction followed by the subheading and main content.

        Then I used the new toSeparatePlaceholders parameter to split up the two columns, allowing me to have three articles in a column of width grid_6, then a narrower second column of grid_3.

        And I also added the pagination to the bottom of the second, narrower column.


        The nice thing about this is as more content is added to the website the older articles get pushed to the second column, giving them less focus than the newer articles.
          MODX Ambassador for Thailand. Managing Director at Monogon, a web design and development studio based in Bangkok, Thailand. - Follow me on Twitter.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          You can also play with CSS3
          article {
          	float:left;
          	width:660px;
          	padding-left:20px;
          	text-align:left;
          	overflow:hidden;
          }
          article p {
          	margin:10px 0px;
          }
          article p:first-of-type {
          	float:left;
          	padding-right:40px;
          	width:310px;
          }
          article > p:nth-of-type(2) {
          	float:left;
          	width:310px;
          }
          article > p:nth-of-type(3) {
          	float:left;
          	clear:left;
          	border-top:1px solid #dad2d2;
          	padding-top:10px;
          	margin:10px 0px;
          }
          
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 18463
            • 121 Posts
            Martijn van Turnhout Reply #5, 15 years, 7 months ago
            Or play with the CSS3 column-property wink

            http://www.css3.info/preview/multi-column-layout/
              • 11055 ☆ A M B ☆
              • 3,112 Posts
              Quote from: Adam at Mar 29, 2011, 04:09 AM

              I’ve come across jQuery plugins such as Columnizer but I don’t think its the best solution, and ideally I’d like to use something MODX native.
              I don’t think that MODX should provide its native CSS grid system.
              You can just pick one of them from outside there.
              And MODX templating system makes you easy to use it.
              I have tried 960.gs, Fluid 960 Grid System, and YUI 2: Grids CSS.
                Rico
                Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
                MODx is great, but knowing how to use it well makes it perfect!

                www.virtudraft.com

                Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

                Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

                Maintainter/contributor of Babel

                Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Indeed, MODx organizes, generates and presents your content. It’s up to you how you want it structured and styled.

                That is actually one of the greatest strengths of MODx. No restrictions or pre-conceived notions of how your page will actually look. Consider the CSS Zen Garden site. All of the pages use exactly the same HTML structure, but each one has its own unique CSS and images. MODx is like that. We could all use the same template, but everybody would have it styled completely differently.
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 436 ☆ A M B ☆
                  • 265 Posts
                  Susan, the CSS Zen Garden is one of my favourite projects - we should do something like that to show the power of MODX; the MODX Zen Garden wink just sayin’!

                  Anyway, yeah, I was thinking of using CSS3 first, then some kind of browser capability detection to fall back onto the getPage multi-column idea - but I wasn’t sure if this would really be faster.

                  Also, using the CSS3 columns I couldn’t figure out a way to make the articles wrap at the titles, so the left-hand column has exactly three articles and the right-hand column also has exactly three.

                  The only downside I can see to the server-side MODX solution is that when you start using the pagination the deeper pages use the same template; it would be best if the articles went into two equal columns, so the larger left-hand column on the homepage has more prominence out of all the articles; the rest become secondary.
                    MODX Ambassador for Thailand. Managing Director at Monogon, a web design and development studio based in Bangkok, Thailand. - Follow me on Twitter.