We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30491
    • 44 Posts
    Hey guys
    Im running into something that presumably easy to do. I just haven’t managed.
    Im trying to have to different templates used by the same snippet and called within the same document. I haven’t figured out a way to do that. At the moment the template parses through the defaults rowTpl template that i have set for it.

    [[!mySnippet]] (where templateOne is default)
    [[!mySnippet &templateTwo=`templateTwo`]]

    I tried this sort of code: (but to no avail)
    if(isset($templateOne)){$output .= $portf->getChunk($modx->getOption('tpl',$scriptProperties,'templateOne '),$itemArray);}else {$output .= $portf->getChunk($modx->getOption('tpl',$scriptProperties,'templateTwo '),$itemArray)}


    Anyone have an idea on how I should tackle this? Im new to creating snippets/components

    many thanks and peace
    • $template = isset($tempalate) ? $template : $template1;
        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
        • 30491
        • 44 Posts
        thanks, but really hasn’t solved it for me, i get no results from either snippet calls for some reason. I’ll keep digging.
          • 30491
          • 44 Posts
          Found a temporary workaround, by duplicating the snippet, changing the template call within it, and calling it by its new name. I would still appreciate if someone could point a simpler way of achieving this. thaaanks
            • 4172
            • 5,888 Posts
            Its easier for all, who want to help, when you show us your working (or not working) code.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
            • Agreed: we need to see your code.

              I would recommend keeping a single input parameter, e.g. &tpl. It’s fine if you have a default value, but you shouldn’t duplicate inputs or your Snippets just because you’re expecting different inputs: that’s poor architecture. I could comment on your code once you post it.