I’m confused; getProperties is used internally; that is not really a function that needs to be called explicitly, ever.
Ok but I am interesting to have an equivalent. Because I think this could be really usefull.
If you do end up using properties, bear in mind that when you use getProperties() for a snippet, same-name properties in a custom property set specified in the snippet tag will override the default properties and same-name parameters in the snippet tag will override both of those.
This is right for the $scriptProperties array, but ...
I have modified a bit the doodle snippet to do some tests:
1/ The doodle (beta 2) is delivered with a default properties set locked: tpl=’rowTpl’, sort=’name’, dir =’desc’. these values are provided with the build process thru the data/properties/properties.php.
2/ I have set up a property set named "newTpl" with tpl=’newTpl’. This property set override the ’rowTpl’ default value.
3/ I call Doodles like this : [[Doodles@newTpl? &sort=`description` &dir=`ASC`]]
So the default tpl, sort and dir properties are overriden by the "newTpl" property set and by the properties passed thru the snippet call : &sort=`description` &dir=`ASC`
4/ I have modified a bit the snippet script in order to display some values:
/* show default properties */
$snippet = $modx->getObject('modSnippet',array('name'=>'Doodles'));
$properties = $snippet->getProperties();
$output = '';
foreach($properties as $key=>$value) {
$output .= "$key = $value, ";
}
echo "default properties: " . $output . "<br /><br />";
/* show newTpl properties */
$propSet = $modx->getObject('modPropertySet',array('name'=>'newTpl'));
$newTplProperties = $propSet->getProperties();
$output = '';
foreach($newTplProperties as $key=>$value) {
$output .= "$key = $value, ";
}
echo "newTpl properties: " . $output . "<br /><br />";
/* show final properties */
$output = '';
foreach($scriptProperties as $key=>$value) {
$output .= "$key = $value, ";
}
echo "script properties: " . $output . "<br /><br />";
I get the following result result:
default properties: tpl = rowTpl, sort = name, dir = DESC,
newTpl properties: tpl = newTpl,
script properties: tpl = newTpl, sort = description, dir = ASC,
Which is interesting is that I correctly get the default property set by using:
$snippet = $modx->getObject('modSnippet',array('name'=>'Doodles'));
$properties = $snippet->getProperties();
So Jason, does it possible to have in the futur a public non-internal method to retrieve these default values like the $snippet->getProperties() ?