? Success

User tests: Successful: Unsuccessful:

avatar andrepereiradasilva
andrepereiradasilva
24 Nov 2015

Description

This PR adds regexReplaceInTemplate function to JDocumentHTML

This can be used for adding/replacing html in the current template, like, for instance, adding HTML5 data-* attributes used by javascript.

Examples of usage:

JFactory::getDocument()->regexReplaceInTemplate('<body', '<body data-json=\''.json_encode(array('item1' => 'value1', 'item2' => 'value2')).'\'');
JFactory::getDocument()->regexReplaceInTemplate('<body', '<body data-var="1"');

Of course, since is a regex replace of the template HTML this can be used for many other things before the final html is rendered.

How to test

  1. Add one of the examples above somewhere in /libraries/cms/html/behaviour.php. I added in the caption function.
  2. Go to homepage and check if in the HTML code there is the following code: <body data-json='{"item1":"value1","item2":"value2"}'

B/C

None

avatar andrepereiradasilva andrepereiradasilva - open - 24 Nov 2015
avatar andrepereiradasilva andrepereiradasilva - change - 24 Nov 2015
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 24 Nov 2015
Labels Added: ?
avatar andrepereiradasilva andrepereiradasilva - change - 24 Nov 2015
The description was changed
avatar andrepereiradasilva
andrepereiradasilva - comment - 24 Nov 2015

this doen't work on admin template so i will close it and try another way.

avatar andrepereiradasilva andrepereiradasilva - change - 24 Nov 2015
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2015-11-24 15:57:13
Closed_By andrepereiradasilva
avatar andrepereiradasilva andrepereiradasilva - close - 24 Nov 2015
avatar andrepereiradasilva andrepereiradasilva - close - 24 Nov 2015
avatar andrepereiradasilva andrepereiradasilva - head_ref_deleted - 25 Nov 2015

Add a Comment

Login with GitHub to post a comment