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

[#31203] The one way and the one container for store the script options #1319

Closed
wants to merge 9 commits into from

Conversation

Fedik
Copy link
Member

@Fedik Fedik commented Jun 22, 2013

In current state the developers add the script options as global variables via addScriptDeclaration, that can be not always safe, and not nice. This path allow to store options in the one global object, where the options separated by the extension name.
The options stays as array until header render, that allow to simple overwrite it if need.

Example add the script option:

$options = array(
  'showAlert' => false,
  'consolelog' => true,
  'text' => 'Hi! I am "Text"!',
  'someArray' => array('one', 'two', 'and so on')
);
$doc->setScriptOptions($options, 'plg_examplejs');

Access to the options in frontend:

Joomla.optionsStorage.plg_examplejs;

Links:

@Fedik
Copy link
Member Author

Fedik commented Jun 22, 2013

nice tip, need to try...
what with a typo you mean? for me looks good :)

about JSON_FORCE_OBJECT I think it no need cause it convert the non-associative array to object that not really nice in case when you need to have the array in the options

@piotr-cz
Copy link
Contributor

I meant you're missing P: _scripts_oPtions

Your are right about JSON_FORCE_OBJECT. I just copied that from my code :)

@Fedik
Copy link
Member Author

Fedik commented Jun 22, 2013

ah hahaha
I thought you mean _scripts_options ...
thanks! really not seen :)
now should be better ;)

@Fedik
Copy link
Member Author

Fedik commented Feb 8, 2014

pull to staging #3072

@Fedik Fedik closed this Feb 8, 2014
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

Successfully merging this pull request may close these issues.

None yet

2 participants