We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14883 ☆ A M B ☆
    • 450 Posts
    I made my first attempt at using property sets with my templates, rather than setting parameters explicity. Instead of this:

    [[$html?
    &customCssChunk=`wwwCssBlock`
    &customScriptsChunk=`wwwScriptsBlock`
    &customTopDesignChunk=`wwwTopDesignBlock`
    &customHeaderChunk=`wwwHeader`
    &navigationChunk=`wwwNavigation`
    &contentLayout=`75_25`
    &customFooterChunk=`wwwFooter`
    ]]

    I created a property set called wwwTemplate, and changed the template code to this:

    [[$html@wwwTemplate? &contentLayout=`75_25`]]

    ("contentLayout" is the one parameter that can vary within that design/template family, so I kept it out of the property set).

    I’ve also added the wwwTemplate property set to my template AND (after that didn’t work) to my $html chunk.

    This isn’t working though. My two theories on why are

    • I’m doing it wrong
    • Property sets don’t work quite the way I was expecting them to

    The way my templates work is, those parameter values are the names of chunks, and they get swapped in to placeholders in order to call those chunks. But this all happens several levels deep: [[$html]] calls [[$head]], which calls [[$css]], which calls [[$css]], which has the placeholder [[$[[+customCssChunk]]]]. With direct parameter calls, this all just works... somehow [[$html]] manages to pass the value for +customCssChunk on through all those other chunks so it behaves the way I need it to. (I realize/confess that I am woefully ignorant on the order in which chunks get parsed).

    Is there a reason why this wouldn’t/shouldn’t work with a Property Set? Or am I doing it wrong? Do I maybe need to add that property set to all of the chunks involved?




      • 22303 MODX Staff
      • 10,725 Posts
      The parsing order is definitely important here, but this is because the values in the property sets are not parsed before arriving in the process() method of any Element. I ran across this same thing when building my new site this past week. I’ve been debating if I should go ahead and process the values of the properties passed via a property set, and I think this has convinced me that this is indeed a more consistent approach.

      Thoughts before I make a change and test the affects?

      NOTE: FWIW, I think I’ve known about this for a while but wasn’t sure if it was a feature (using properties in property sets, or default properties, avoids having tags that appear in their values pre-parsed), or a bug (it’s not pre-parsing the tags in the properties from property sets, or default properties).
        • 14883 ☆ A M B ☆
        • 450 Posts
        Hard to say... consistency vs. having two different ways to handle properties. In my case I’d like to have the properties get processed; but I could see the case to be made on the other side... having a way to assign properties to an outer element without having them affect inner elements. Maybe make it configurable, similar to how you set an element as uncached with the ’!’... [[$chunk@!propertyset]] I have no idea if this makes sense or not, or would be useful or not.
          • 22303 MODX Staff
          • 10,725 Posts
          I’m going to have to vote on the side of consistency here. I think they should always get pre-processed. I see more benefit in this, than in encouraging tags you want to use inside the logic to appear in the properties. This is the purpose of encapsulating a tpl in a Chunk IMO.