Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$modx->getOption default values (when system setting is empty) #33

Open
danFWD opened this issue Apr 1, 2016 · 2 comments
Open

$modx->getOption default values (when system setting is empty) #33

danFWD opened this issue Apr 1, 2016 · 2 comments

Comments

@danFWD
Copy link

danFWD commented Apr 1, 2016

Another issue I'm coming across, specifically in the Snippet "getPagesByTerm" is that the $modx->getOption method only returns the default value if the fourth attribute $skipEmpty is set to true. From the official documentation:

$default: the value to return when the key was not found.
$skipEmpty: when set to true, the $default will also be returned if the $key's value is an empty string. Added in xPDO 2.2.1 / MODX 2.2.0-rc2.

This is causing the SQL queries to error since the options values are empty. I'm not sure why the developers at MODx decided to change this feature, but it is a freakin’ time-bomb. It should have been "$doNotSkipEmpty" for backwards compatibility reasons.

@moniarde
Copy link

moniarde commented Apr 5, 2017

+1 to this. Add ',true' to the end of each getOption statement, or pre-populate properties with default output (or both).

@moniarde
Copy link

Exists also for other snippets, ie getPagesByTerm. Updated code below:

$debug = $modx->getOption('debug', $scriptProperties);
$classname = $modx->getOption('classname', $scriptProperties, 'PageTerm', true);
$term_id = $modx->getOption('term_id', $scriptProperties);
$exact_matches = $modx->getOption('exact_matches', $scriptProperties);
$graph = $modx->getOption('graph', $scriptProperties, '{"Page":{}}',true);
$outerTpl = $modx->getOption('outerTpl',$scriptProperties, '<ul>[[+content]]</ul>',true);
$innerTpl = $modx->getOption('innerTpl',$scriptProperties, '<li><a href="[[~[[+Page.id]]]]">[[+Page.pagetitle]]</a></li>',true);
$sort = $modx->getOption('sort', $scriptProperties,'pagetitle',true);
$dir = $modx->getOption('dir', $scriptProperties,'ASC',true);
$limit = $modx->getOption('limit', $scriptProperties);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants