Coroico / AdvSearch

Dynamic content search add-on for MODx Revolution that supports results highlighting, faceted search and search in custom packages
21 stars 14 forks source link

Update core/components/advsearch/model/advsearch/advsearchform.class.php #41

Closed yongzhenlow closed 11 years ago

yongzhenlow commented 11 years ago

Added conditional so that if user chose 0 for addJs, inline js would not be output. This is because advsea var was not initialized as the prior js files were not loaded.

I've also added the js to check advsea for undefined as an extra measure, since this would be prove useful if your intentions were to allow access to these vars even if addJs was 0. In that case, you can remove my first change, while keeping the js.

Coroico commented 11 years ago

addJs var is initialized with:

    // &addJs - [ 0 | 1 | 2 ]
    $addJs = (int) $this->modx->getOption('addJs', $this->config, 1);
    $this->config['addJs'] = ($addJs == 0 || $addJs == 1 || $addJs == 2) ? $addJs : 1;

inside _checkParams function prior to use it.

yongzhenlow commented 11 years ago

@Coroico I think you misunderstand. If the user disables js with &addJS=0`, the browser will throw erroradvsea is undefined`. That's what this patch is for.

(PS: i removed the branch, that's why the pull request was closed. Let me know if you want me to send again.)