Same code in a component and a Jumi module

A multipurpose module, plugin and component

Same code in a component and a Jumi module

New postby [email protected] » Sun Nov 28, 2010 8:58 am

I have been using Jumi for quite a while on my site (boca.org.au) and it is great. Recently however I needed to get some PHP code to work both within a Jumi module and in a freestanding component that I wrote.
I have a very simple problem - the code has a routine

function format_money($s)
{
return sprintf("$%01.2f",$s);
}
which works well in the component I have written. However when I call it in the Jumi module - and it is passed exactly the same parameters as it reads the values from a database in both cases - it returns either ".00" or "0.00" no matter what the input value.
Any ideas welcomed!
Thanks
Dave

(Previously posted on forum.joomla.org)
[email protected]
 
Posts: 3
Joined: Sun Nov 28, 2010 8:56 am

Re: Same code in a component and a Jumi module

New postby [email protected] » Mon Nov 29, 2010 7:00 am

I have a work around but I am still slightly baffled!
If I use sprintf("$%01.2f",$s) (i.e. use the HTML code for $) then the code works in both Jumi and my Joomla component - whereas the original worked only in the component.
[email protected]
 
Posts: 3
Joined: Sun Nov 28, 2010 8:56 am

Re: Same code in a component and a Jumi module

New postby Edvard » Mon Nov 29, 2010 1:14 pm

When you put the code in jumi module it is being saved in the module parameters with some format joomla uses for parameters. It seems that the joomla parameter parser have some issues with parsing the code. So it will be better to include a file with module if your code is long and have special characters in it.
Regards,

Edvard Ananyan - 2GLux Team

Please post a review at the Joomla Extensions Directory. It is very important for us!
Edvard
Site Admin
 
Posts: 1836
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Same code in a component and a Jumi module

New postby [email protected] » Tue Nov 30, 2010 1:19 am

Thanks - I have found another instance where the behaviour is not the same in PHP code in a Jumi module compared to in a Joomla component - and again it involved the $ character. So clearly as you say the parser is doing something here - anyway I know the problem and the workaround now!
[email protected]
 
Posts: 3
Joined: Sun Nov 28, 2010 8:56 am


Return to Jumi

Who is online

Users browsing this forum: No registered users and 2 guests