Loading language file & parameters from another component?

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Locked
User avatar
ljk
Joomla! Guru
Joomla! Guru
Posts: 756
Joined: Sat Jan 28, 2006 11:51 pm
Location: West Kelowna, BC
Contact:

Loading language file & parameters from another component?

Post by ljk » Sat Mar 20, 2010 9:50 pm

Hello,

Is it possible to load the language file and component parameters from another component when executing code in another component? For example, I need to add code to component x, which is coming from component y. In the code added to component x it needs to get parameter values and language files from component y.

What code would I use to load the parameters from component y and access component y's language entries when I am executing code in component x?

Any help would be appreciated.
Laurelle
Keashly.ca Consulting
http://www.keashly.ca

jeffchannell
Joomla! Ace
Joomla! Ace
Posts: 1964
Joined: Tue Jun 09, 2009 2:21 am
Location: WV
Contact:

Re: Loading language file & parameters from another component?

Post by jeffchannell » Sun Mar 21, 2010 1:21 am

$otherlanguage =& JFactory::getLanguage();
$otherlanguage->load( 'com_othercomponent', JPATH_SITE );

and

$otherparams =& JComponentHelper::getParams( 'com_othercomponent' );

??
http://jeffchannell.com - Joomla Extensions & Support
http://biziant.com - Open Joomla Firewall/IDS
Unsolicited private messages/emails = hire me to fix your problem.
καλλιστι

User avatar
ljk
Joomla! Guru
Joomla! Guru
Posts: 756
Joined: Sat Jan 28, 2006 11:51 pm
Location: West Kelowna, BC
Contact:

Re: Loading language file & parameters from another component?

Post by ljk » Sun Mar 21, 2010 10:03 pm

Hello,

Thank you for your help.

Next question, how do I access the component parameters. I tried:

Code: Select all

      $pos_params = & JComponentHelper::getParams('com_posuid');
      return $pos_params->get('e-commerce-detail6');
and this is what is in config.xml for com_posuid:

Code: Select all

    
<param type="text" name="e-commerce-detail6" label="Shopper Group ID" default="5" description="default: 5" class="" cols="3" rows="1"/>
So, I expected that I would get 5 returned, but I am getting nothing returned.

I really appreciate you help.

Thank you.
Laurelle
Keashly.ca Consulting
http://www.keashly.ca

jeffchannell
Joomla! Ace
Joomla! Ace
Posts: 1964
Joined: Tue Jun 09, 2009 2:21 am
Location: WV
Contact:

Re: Loading language file & parameters from another component?

Post by jeffchannell » Sun Mar 21, 2010 10:21 pm

Have you tried defining a default in your return?

Code: Select all

      $pos_params = & JComponentHelper::getParams('com_posuid');
      return $pos_params->get('e-commerce-detail6', 5);
You might also try fetching the params via the menu, as I believe that should have all of the params (including those that are overridden by that menu item).

Another option is to fetch them raw directly from the __components database table and feed them into a new JParameter instance ( http://api.joomla.org/Joomla-Framework/ ... meter.html ).
http://jeffchannell.com - Joomla Extensions & Support
http://biziant.com - Open Joomla Firewall/IDS
Unsolicited private messages/emails = hire me to fix your problem.
καλλιστι

User avatar
ljk
Joomla! Guru
Joomla! Guru
Posts: 756
Joined: Sat Jan 28, 2006 11:51 pm
Location: West Kelowna, BC
Contact:

Re: Loading language file & parameters from another component?

Post by ljk » Wed Mar 24, 2010 11:08 pm

Hello,

Once again thank you for your help.

I figured out why I wasn't getting anything returned using:

Code: Select all

$pos_params = & JComponentHelper::getParams('com_posuid');
      return $pos_params->get('e-commerce-detail6');
It was because there was no parameters stored in the component params field yet. Once I saved the Parameters in the backend, then this worked great.

I continue reading the documentation for parameters and it has this statement:
Note that there is no need to define default attributes for the <param /> elements in the config.xml file, since the default values will already have been saved in the installation of the Component.
on this page: http://docs.joomla.org/Component_parameters.
Do you have to define the parameters in the config.xml file in the installation file for the component in order for the default values to get saved into the database? Or how do the default attributes get saved in the installation of the component. I obviously have missed something.

Thanks again, you have been so helpful. I really appreciate you taking the time to answer these newbie questions.
Laurelle
Keashly.ca Consulting
http://www.keashly.ca


Locked

Return to “Joomla! 1.5 Coding”