Youjoomla Support Forums (
-   Eximium (
-   -   [SOLVED] Custom Code in Template Manager (

achartier 09-20-2014 11:15 PM

[SOLVED] Custom Code in Template Manager
This thread should probably move to the YJSG Framework Plugin category.

First question is does the custom code I add via the template manager get passed through the joomla content/system plugins?

Assuming it does, when I place some code in one of these fields I am getting a "Required JSON Parse Failed" error.

The code I am trying to include is php code wrapped in content tags. Assuming the joomla content/system plugins get called on this inclusion the content tag is interpreted, the php code is executed by the plugin, and html is returned.


Are you sure your are posting in product assigned forum?: Yes

What is your CMS version?: Joomla 2.5

MySQL Version: 5.x

PHP version: 5.x

Link to installation: unavaliable

Have you edited any files? If yes tell us which ones.: No

Is this personal or client website?: Personal

achartier 09-21-2014 07:55 AM

I moved the code to the after <body> tag and now the template manager saves it OK, no more JSON error. The code is getting placed correctly but it does not appear it is being passed through the joomla plugin system.

What I am trying to accomplish is to display a YJSG Notification once upon login, independent of how the user logs in (normal login form, Kunena login, lost password login etc as each of these end up on a different page). So what I wanted to do was place some code at the top of the body to test for the existence of a cookie and if not present show the notification and set the cookie, if the cookie is present then skip the notification.

This all works when I place the code into an article using NoNumber Sourcerer. But the source tags are not being processed when the code lives in the After <Body> tag in Template Manager.

I imagine I can accomplish this by modifying the Eximium template index.php file or one of the other files but I really try an stay away from directly modifying component/plugin/template files for upgrade and support reasons.

Any help you can provide would be appreciated.

neo 09-21-2014 08:20 AM

php code is not accepted there. is not being parsed and is not connected to plugins
use any code except php

neo 09-21-2014 08:22 AM

to add php code use yjsg_custom_params.php file , this is why it is there

Using Custom params file | Advanced | Documentation

achartier 09-21-2014 09:44 AM

OK, thanks I will look at that option.

achartier 09-21-2014 10:01 AM

That looks like it is the place, this will be very helpful for many things.

Is there a list of vars that I can append to? I see for adding js, how about if I want to add html to the head or body sections?

neo 09-21-2014 10:23 AM

html and all other tags work fine from admin , only php should be added in that file, and that file is yours , it is not overwritten on install

achartier 09-21-2014 10:41 AM

Understood, but what I want to do is have my php, based on some criteria, insert html into the top of the body. The html I am looking to insert at this point is a yjsg notification shortcode but it could be anything.

achartier 09-22-2014 10:48 AM

Neo, any pointer on this? Inserting html via php in custom params file?


neo 09-22-2014 11:04 AM

sure we do it all the time

$myhtml ='<div class="happy">Hello</div>';

echo the $myhtml variable in template index.php

or if you want to use the afterbody with php contidions
do the magic like this inside the custom params file

PHP Code:

$afterbody   $this->params->get('cc_after_body');// if it is used , we want everything that is in there
$afterbody     .='<div class="happy">Hello</div>';// adding my stuff

$this->params->set('cc_after_body',$afterbody);// set the new afterbody 

this way there is no need to echo anything in index, you just keep on adding the params with your conditions/html ect and they will be printed after the body tag

All times are GMT -4. The time now is 03:55 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.