We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21106
    • 53 Posts
    I’m setting up a blog powered by ModX CMS. The blog is divided into three containers: Music, Movies & Artworks. The homepage will display 10 of the latest published blog entries. I wanted to assign different TPLs for each of the three containers so they have their own styling. This is within a single getResources call.

    Is it possible?
      • 4172
      • 5,888 Posts
      you can use the if-snippet or output-filter to switch the tpls for example depending on parents or give your chunks a name with the parent-id as suffix

      in your tpl-chunk for example:

      [[$myTpl_[[+parent]]]]


      and use chunknames for different parents like: myTpl_3, myTpl_5, myTpl_10

        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 21106
        • 53 Posts
        Thanks for the hint, Bruno17. I tried this but I’m still confused with how the it will be configured.

        I tried to set it up but stumbled on something. Here’s the structure of the website:

        Homepage
        - Music
        - Musicians
        - Article 1
        - Article 2

        - Movies
        - Article 1
        - Article 2

        - Artworks
        - Article 1
        - Article 2

        Using UltimateParent & If, I created the following chunk with the name iftemplate:

        [[!If? &subject=`[[UltimateParent? &id=`[[+id]]` &topLevel=`2`]]` &operator=`EQ` &operand=`2` &then=`latestart` &else=`latestart2`]]


        latestart is the first TPL chunk, the alternative TPL chunk is latestart2.

        Then I call them on the homepage template with:

        [[!getResources? &parents=`2,20,26` &tpl=`[[$iftemplate]]`  &limit=`10` &hideContainers=`1`]]


        The conditional statement works but when the getResources statement is called on the homepage, the template sticks to using latestart2 as the TPL chunk. I’m pretty sure I skip some more processing. Or I might have been deluded and approached the problem on the wrong side. huh
          • 4172
          • 5,888 Posts
          first I would try it without if-snippet, this way:

          [[$latestart_[[getResourceField? &id=`[[UltimateParent? &id=`[[+id]]` &topLevel=`2`]]` &field=`parent`]]]]
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!