betweenbrain™ | web • print • idenity • creative

  • Content
  • Navigation
  • Home
  • Services
  • Process
  • Contact
  • About
  • Notes
  • Download

Call Joomla! Template Parameter From Template Override

Last Updated on Thursday, 04 February 2010 18:11

Here's a beauty of a gem for all of you template-override-happy, parameter junkies (I'm one too!). You can call template based parameters (hint: add your own) from within a template override. This first bit was originally posted at the Joomla! forums by okonomiyaki3000:

<?php 
global $mainframe;
jimport('joomla.filesystem.file');
$tparams = new JParameter(JFile::read(JPATH_BASE.DS.'templates'.DS.$mainframe->getTemplate().DS.'params.ini'));
?>

This allows you to read the template parameters. Then you can call one of them as follows:

<?php echo $tparams->get('redirectUrl'); ?>

Now, if that's not enough fun for you, we can mix in some JavaScript. For example, we'll take a newly created redirect parameter and slap it in the middle of a redirect, resulting in:

<script type="text/javascript"> window.setTimeout('window.location="<?php echo ($tparams->get('redirectUrl')); ?>"; ',1); </script>

NOTE: The Art of Web posted a nice write-up entitled "PHP: Passing variables to JavaScript that could come in handy.

Add comment

We'd like to hear what you think. As long as it's constructive, we'll publish it.


Security code
Refresh

Send
Cancel
JComments
Going up?
feed-image Feed Entries
  • Home
  • Services
  • Process
  • Contact
  • About
  • Notes
  • Download
  • Search
  • Sitemap

All rights reserved. © 2010 betweenbrain™
Developed using the Construct Template Development Framework
Joomla! is a registered trademark of Open Source Matters, Inc. - Disclaimer