Hello there! Welcome to Youjoomla Support Forums

We are Web Development Company specializing in Joomla Templates , Joomla Extensions and WordPress Themes development . You are not able to see some forum threads due to your memberhip level. To unlock all forums and special customer support please take few moments to signup . If you are just searching for free joomla templates , or free joomla extension support simply head to our Free Joomla Support forums and open a new thread. Our moderators will help you as soon as possible. To spead up the response time please take few seconds and go over forum rules

Have fun!

[SOLVED] Custom Code in Template Manager

09-20-2014, 11:15 PM
# 1 (permalink)
achartier
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.

TIA.

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
09-21-2014, 07:55 AM
# 2 (permalink)
achartier
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.
09-21-2014, 09:44 AM
# 5 (permalink)
achartier
OK, thanks I will look at that option.
09-21-2014, 10:01 AM
# 6 (permalink)
achartier
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?
09-21-2014, 10:23 AM
# 7 (permalink)
neo
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
09-21-2014, 10:41 AM
# 8 (permalink)
achartier
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.
09-22-2014, 10:48 AM
# 9 (permalink)
achartier
Neo, any pointer on this? Inserting html via php in custom params file?

Thanks.
09-22-2014, 11:04 AM
# 10 (permalink)
neo
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
Thread Tools
Display Modes

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

Members Login

Username
Password