Welcome, Guest
Username Password: Remember me

[Solved] Can't access template parameter
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: [Solved] Can't access template parameter

[Solved] Can't access template parameter 12 years, 8 months ago #4856

  • sim085
  • OFFLINE
  • Junior Boarder
  • Posts: 24
  • Karma: 0
Hello, I defined a template parameter inside the templateDetails.xml file as follows ...

 
<config>
<fields name="params">
<fieldset name="BASIC">
<field name="logo" type="media"
label="Logo" description="Please choose an image." />
</fieldset>
</fields>
</config>
 


Inside my index.php file I have the following code ...

 
<?php
$logo = $this->params->get('logo');
?>
logo=<?php echo htmlspecialchars($logo); ?>
 


However, even though I am defining the image I want to load, when I try to print the logo image path I get an empty string back. The same code works fine from the template I used as default (normal browser that is).

Am I doing something wrong?
Last Edit: 12 years, 8 months ago by sim085.

Re: Can't access template parameter 12 years, 8 months ago #4857

  • sim085
  • OFFLINE
  • Junior Boarder
  • Posts: 24
  • Karma: 0
I did a quick test on the mobile_iphone template which "seemed" it makes use of template parameters. However I think that neither this is working. I changed the index.php file as follows ...

 
value = <?php echo $this->params->get('theme', 'NOT_APPLE'); ?>
 


and what I got printed on the site is "NOT_APPLE". In other words it seems that the get(...) method did not manage to get the value and therefore used the given default "NOT_APPLE" (the opens from Template Manager for this theme are "apple" and "jqt").

Is there a way how template parameters can be loaded for mobile sites using Mobile Joomla? Or some alternative to get parameters passed?

Re: Can't access template parameter 12 years, 8 months ago #4870

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4866
  • Karma: 105
Seems there are two "features" in J1.6+ (but I didn't dig through):
1. Fields should have default="<default value>" attribute to be added into list of params on install.
2. List of params is not updated on template update, so you should to uninstall previous version of template before installing new one.

Re: Can't access template parameter 12 years, 8 months ago #4874

  • sim085
  • OFFLINE
  • Junior Boarder
  • Posts: 24
  • Karma: 0
Hi thanks for your reply however still did not manage to make it work. Indeed the same syntax works fine when used in a normal Joomla template.

my templateDetails.xml file is as follows;

 
<params>
<param name="logo" type="media" default="default value"
label="Logo"
description="Please choose an image.">
</param>
</params>
<config>
<fields name="params">
<fieldset name="BASIC">
<field name="logo" type="media" default="default value"
label="Logo"
description="Please choose an image." />
</fieldset>
</fields>
</config>
 


In the index.php file I use the following code ...

 
<?php
$logo = $this->params->get('logo', 'nologo');
?>
logo=<?php echo htmlspecialchars($logo); ?>
 


What I get printed is "nologo". This - for me - also happens with the one of the templates that comes with mobile Joomla. It seems as if the $this.params.get() does not return anything!!

EDIT: I also unistalled the template and then re-installed it (from the discover option). The result is the same.
Last Edit: 12 years, 8 months ago by sim085.

Re: Can't access template parameter 12 years, 8 months ago #4878

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4866
  • Karma: 105
What Joomla release do you use?

Re: Can't access template parameter 12 years, 8 months ago #4879

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4866
  • Karma: 105
And try to clear joomla's cache.

Re: Can't access template parameter 12 years, 8 months ago #4900

  • sim085
  • OFFLINE
  • Junior Boarder
  • Posts: 24
  • Karma: 0
I use Joomla 1.6.3, and at the moment I have no cache enabled. Could it be that template paramters only work when the template is selected as default? I am saying this because not even mobile_iphone template works for me (put in index.php <?php echo $this->params->get('theme', 'NOT_APPLE'); ?> and you will get 'NOT_APPLE' in value, at least that is what happens for me).

Re: Can't access template parameter 12 years, 8 months ago #4902

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4866
  • Karma: 105
Yes, you are right, Joomla!1.6+ doesn't load params on template change. Hope this patch should work: github.com/mobilejoomla/mobilejoomla/commit/3ae20c8699997f27c2e93ed1b60ed28851df3435

Re: Can't access template parameter 12 years, 8 months ago #4903

  • sim085
  • OFFLINE
  • Junior Boarder
  • Posts: 24
  • Karma: 0
How can I install this fix? A very big thanks for your help.
Last Edit: 12 years, 8 months ago by sim085.

Re: Can't access template parameter 12 years, 8 months ago #4905

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4866
  • Karma: 105
Edit plugins/mobilebot/mobilebot.php as described in the patch (red background color means remove of the corresponding line, green color means insert the line, and white color corresponds to nonchangeable lines used to localize block of text to change).
  • Page:
  • 1
  • 2
Time to create page: 0.28 seconds

By continuing to use this site you consent to the use of cookies on your device as described in our cookie policy unless you have disabled them. This site will not function correctly without cookies.

I accept cookies from this site.