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

    I have started to develop my first site in MODx and it's going quite fine.

    I have a problem that might have a better solutions then what I'm thinking.

    Problem:
    Print four news (with the articles plugin), two in each row and have an <hr> after the first two.
    eg.
    news 1 | news 2
    ---------------
    news 3 | news 4


    I can't count the number of articles already printed and insert an <hr>, the template only allows me to set the code for each article, if there wasn't a line between them I would have no problem but unfortunately there is. So basically I need two news per row in a total of four.

    The only way I can think of to solve this problem is to create a new snippet and use getResources to manipulate the data and count it. This would also require me to change/create a pagination snippet and I would like to avoid this solution (too much work and time) if at all possible.

    I'm writing this post because there must be a better (and much more simple) way to do this in MODx, so I've turned to the experts ;-), hope you guys can help.

    Thanks,
    Pedro Santos
    • Hi Pedro,

      responding to your idea of using getResources - you could still use getPage to create your pagination for you. getPage is not only limited to the Articles add-on. There are examples shown here:

      http://rtfm.modx.com/extras/revo/getpage

      Another way to do this would be just by using pure CSS and throw out your hr tag. You could target every 2nd list item element in your output, give it a display:block with a border-bottom attribute.

      http://css-tricks.com/how-nth-child-works/

      Those are just to ideas off the top of my head.

      Cheers!

        Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.
      • On second thought, my css recommendation won't work the way I imagined, but I think there must be a way to achieve it with CSS. The display:block would of course also separate the selected list item from the one above it and you would not achieve the effect you were looking for.

        You wouldn't need a new snippet for using getResources to create a news list. Here is some documentation for collecting news articles from Articles by the use of getResources:

        http://rtfm.modx.com/extras/revo/articles/articles.retrieving-articles-outside-of-articles [ed. note: sonicpunk last edited this post 9 years, 3 months ago.]
          Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.
        • One thing I would also recommend for creating a blog or news area would be to NOT work with Articles, but work with the collections add-on:

          http://rtfm.modx.com/extras/revo/collections

          Then you just use getResources and getPage to create your article lists. It leaves you more control of your output and IMHO it is simpler to set up. [ed. note: sonicpunk last edited this post 9 years, 3 months ago.]
            Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.