How can I access the globalOptions in a component? #572
-
I want to access globalOptions that are created in a tab within a component. Unfortunately, I always get “NULL”. Do you have a sample code for me? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey, retrieving fields from a tab within a component should be straightforward: Here's an example: Please also note that If you require further support, please post your code snippet for further investigation of the problem. |
Beta Was this translation helpful? Give feedback.
Hey, retrieving fields from a tab within a component should be straightforward:
While fields in tabs are visually nested, they're available on the top level in the data structure.
Here's an example:
BlockWysiwyg/functions.php: Definition of tabs (Content | Options) and fields (contentHtml, options).
BlockWysiwyg/index.twig: Rendering of fields (contentHtml, options.*).
Please also note that
globalOptions
are a different concept to store and retrieve settings for the whole site. WithOptions::addGlobal()
you can add options to the Global Options page and retrieve them withOptions::getGlobal()
.If you require further support, please post your code snippet for further investigation of the p…