Compatible XF Versions:
No
This product reads XenForo cookies into template params (session, session_admin and user excluded). This avoids the need to create new tables or modify existing ones to store user options in add-on products and makes it possible to use them when templates are rendered without having to extend classes. Cookie values are filtered using the same method as XenForo uses for filtering get and post inputs.
Cookie values are available as $visitor.cookie.(cookie name). Example:
If the cookie value is a well-formed JSON string it is automatically parsed and available under a new index ending in "_json". Depth of the JSON object is almost unlimited (512).
Example:
A unique page name, {$pageName} is also generated and is available in almost all templates. Its value is based on $controllerName and $controllerAction. (See this thread.) This parameter can be used in cookie names to make settings for each page.
A demo template "nerbert_templatecookies_demo" is provided to illustrate use of cookies for a collapse box, checkboxes, radio buttons, JSON cookies, generating default cookies and the use of {$pageName}. See js/nerbert/demo.js for details in the comments.
I developed this in version 1.5.1. I don't know about compatibility with earlier versions. Let me know.
Installation: the usual, unzip the file, upload the provided files in your main directory and upload the product xml file in admin CP. This product has no control panel. If you are not using $pageName you can disable the "template_create" listener.
- 1.5
No
This product reads XenForo cookies into template params (session, session_admin and user excluded). This avoids the need to create new tables or modify existing ones to store user options in add-on products and makes it possible to use them when templates are rendered without having to extend classes. Cookie values are filtered using the same method as XenForo uses for filtering get and post inputs.
Cookie values are available as $visitor.cookie.(cookie name). Example:
{$visitor.cookie.vanilla_cookie}
If the cookie value is a well-formed JSON string it is automatically parsed and available under a new index ending in "_json". Depth of the JSON object is almost unlimited (512).
Example:
$.setCookie('vanilla_cookie', '{"foo":"bar","razzle":"dazzle"}', expires);
{$visitor.cookie.vanilla_cookie} = {"foo":"bar","razzle":"dazzle"},
{$visitor.cookie.vanilla_cookie_json.foo} = bar,
{$visitor.cookie.vanilla_cookie_json.razzle} = dazzle
{$visitor.cookie.vanilla_cookie} = {"foo":"bar","razzle":"dazzle"},
{$visitor.cookie.vanilla_cookie_json.foo} = bar,
{$visitor.cookie.vanilla_cookie_json.razzle} = dazzle
A unique page name, {$pageName} is also generated and is available in almost all templates. Its value is based on $controllerName and $controllerAction. (See this thread.) This parameter can be used in cookie names to make settings for each page.
A demo template "nerbert_templatecookies_demo" is provided to illustrate use of cookies for a collapse box, checkboxes, radio buttons, JSON cookies, generating default cookies and the use of {$pageName}. See js/nerbert/demo.js for details in the comments.
I developed this in version 1.5.1. I don't know about compatibility with earlier versions. Let me know.
Installation: the usual, unzip the file, upload the provided files in your main directory and upload the product xml file in admin CP. This product has no control panel. If you are not using $pageName you can disable the "template_create" listener.