Load template parameters in Output Overrides

530 views
Skip to first unread message

Soheil Novinfard

unread,
Jan 28, 2012, 4:54:07 PM1/28/12
to joomla-de...@googlegroups.com
hi,

I want to load template parameters in Output overrides:
http://docs.joomla.org/Understanding_Output_Overrides

How can I do this?

Thanks,
Novinfard

vahid hajipour

unread,
Jan 28, 2012, 6:06:36 PM1/28/12
to joomla-de...@googlegroups.com

Template parameters from inside a template

  • $param = $this->params->get('paramName', defaultValue);


Template parameters from outside a template

  • code
  • source
  1. $app = JFactory::getApplication('site');
  2. $template = $app->getTemplate(true);
  3. $param = $template->params->get('paramName', defaultValue);

Tarantino

unread,
Jan 29, 2012, 12:48:05 AM1/29/12
to joomla-de...@googlegroups.com
میبینم که شلوغش کردید گروه توسعه رو
ها ها ها
ایشالا یه روز برسه همش ایرانی ها اینجا پست بزنن فعلا 4 نفریم
جناب علوی
سهیل
وحید
شایدم گاهی من

(:

Soheil Novinfard

unread,
Jan 29, 2012, 2:22:16 AM1/29/12
to Joomla! General Development
Thanks hajipour,

Second part is my answer.

بله!!
:D
ایشالا!
هنر نزد ایرانیان است و بس!!!

On Jan 29, 2:06 am, vahid hajipour <click...@gmail.com> wrote:
> Template parameters from inside a template
>
>    - $param = $this->params->get('paramName', defaultValue);
>
> Template parameters from outside a template
>
>    - code
>    - source
>
>    1. $app = JFactory::getApplication('site');
>    2. $template = $app->getTemplate(true);
>    3. $param = $template->params->get('paramName', defaultValue);

Soheil Novinfard

unread,
Jan 29, 2012, 12:33:54 PM1/29/12
to Joomla! General Development
Unfurtunatly this does not work with following errors:


Notice: Trying to get property of non-object in ...
Fatal error: Call to a member function get() on a non-object in ..

the errors refers to this line:
$param = $template->params->get('paramName', defaultValue);

any other idea?

Keith Mountifield

unread,
Jan 29, 2012, 12:44:00 PM1/29/12
to joomla-de...@googlegroups.com
Hi Soheil,

It looks to me (though I may be wrong) that you need to create an instance the JParameter object for which get() is a method.

Try this:


$app = JFactory::getApplication('site');

$template = $app->getTemplate(true);
$templateParams = new JParameter($template->params);
$param = $ templateParams ->get('paramName', defaultValue);

Hope that helps

Best

Keith

any other idea?

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.


Soheil Novinfard

unread,
Jan 29, 2012, 1:09:21 PM1/29/12
to Joomla! General Development
hi Keith and thanks,
but the problem not solved and error is same.
I notice that I use joomla 1.5.

Also, I use this way for solve the problem :

$app = JFactory::getApplication('site');
$template = $app->getTemplate(true);
jimport('joomla.filesystem.file');
$mainframe = &JFactory::getApplication();
$params = $mainframe->getParams(JFile::read(JURI::root() .'/
templates/'. $template .'/params.ini'));
$param = $params->get('paramNamel');

in this case there is no problem, but it not loaded template
parameters, and instead load component parameters that I want to
override in template (html folder of template).
I test the path that is used in getParams and it is true.

Any idea about this?

Keith Mountifield

unread,
Jan 29, 2012, 1:10:14 PM1/29/12
to joomla-de...@googlegroups.com
Ah, didn't realise that you were using J1.5, I think my solution would only work in 1.6 upwards.

Glad you found a solutions..

abhinav verma

unread,
Dec 13, 2013, 8:54:01 AM12/13/13
to joomla-de...@googlegroups.com
Dear Soheil Novinfrad,

i tried your way but wasn't successful so i twisted it a bit instead of using "\" i used DS (Directory Separator) and instead of using $mainframe i used $params = new JParameter so my code looks something like below, but i must say you comments helped me atleast to know in which direction i shall go ahead.. Thanks

my code :

$app = JFactory::getApplication('site');
$template = $app->getTemplate(true);
jimport('joomla.filesystem.file');
$params = new JParameter(JFile::read(JPATH_SITE . DS . 'templates' . DS . $template . DS . 'params.ini'));
$param = $params->get('YOUR_TEMPLATE_PARAM');
Reply all
Reply to author
Forward
0 new messages