How do you template to output across a grid that switches between vertical and horizontal posts? I left the Craft/Trig off.

I know how to loop through and print entries using one orientation. But how do I get it to change direction after every 2 and then switch back again, repeat...

  • It's very hard to tell what you are looking for here... This seems more like a CSS or responsive design question, unless I'm misunderstanding? – Lindsey D Aug 18 '16 at 19:10
  • I did not add the Craft/Twig to this example. Let me try again, I know how to get Craft to repeat one orientation - for example, just horizontal by repeating the mark-up for (in this case) the horizontal entry. But, how do I get it to loop through the entries and at the same time switch every 2 between horizontal and then vertical. – Hellyar Aug 18 '16 at 19:23
  • I would recommend two things to improve this question... (1) Get rid of all extraneous markup (you have tons of classes and extra markup which is distracting from your basic architecture), and (2) include the Twig code that you already know how to use. It is much easier for other people to improve on your existing Twig code, rather than expecting them to write the entire thing for you. – Lindsey D Aug 18 '16 at 19:29
{% if loop.index is divisible by(2) %}stuff{% else %}other-stuff{% endif %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.