We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49347
    • 7 Posts
    Hello!
    Please tell how to use correctly property set in TV output render? How to retrieve properties in descendant of class modTemplateVarOutputRender?
    Firstly I've created property set with required properties and wrote in content construction kind of [[*mytv@propset]].

    This question has been answered by BobRay. See the first response.

      • 3749
      • 24,544 Posts
      The properties are mainly intended just to set placeholder values. If you can have your render class return the placeholders to display, MODX will replace them with their values.

      If that doesn't work, you can get the property set directly (though it's discouraged):

      $pSet = $modx->getObject('modPropertySet', arrray('name' => 'propset'));
      
      if ($pSet) {
         $properties = $pSet->getProperties();
      }


      Another way to go would be to call a snippet:

      [[!snippetName@propset? &tvName=`mytv`]]
      


      The snippet could load your rendering class, get the TV value for a given resource, get the properties from the $scriptProperties array, and return the appropriate content.

      Yet another option, would be to create System Settings rather than a property set. Then you can get their values in your class like this:

      $setting = $mod->getOption('settingName', null);


        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 49347
        • 7 Posts
        The idea is to avoid using snippet and use tv output class as a snippet with parameters. In manager gui it is possible to attach property set to TV, but I can't understand how to extract these properties. sad At the moment of invoking method
        getObject('modPropertySet', arrray('name' => 'propset'));
        name of property set must be known.
        • discuss.answer
          • 3749
          • 24,544 Posts
          MODX will process this tag by getting the TV and replacing any placeholders in the TV that match keys in the property set before returning a value.

          [[*mytv@propset]]


          AFAIK, there's no way to hook into this process, and since a TV can have more than one property set attached to it, there's no way to get one without knowing the name.

          You could call a snippet like this:

          [[!MySnippet? 
              &propertySet=`name_or_id_of_property_set` 
              &tv=`name_or_id_of_tv`
          ]]


          That way you could do whatever you want with the TV and property set.

          It's difficult to advise you on this, since you haven't said what you're trying to accomplish and why. I suspect that a property set is not the best way to solve your problem.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting