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.
Loading language file & parameters from another component?
- ljk
- Joomla! Guru
- Posts: 756
- Joined: Sat Jan 28, 2006 11:51 pm
- Location: West Kelowna, BC
- Contact:
-
- Joomla! Ace
- Posts: 1964
- Joined: Tue Jun 09, 2009 2:21 am
- Location: WV
- Contact:
Re: Loading language file & parameters from another component?
$otherlanguage =& JFactory::getLanguage();
$otherlanguage->load( 'com_othercomponent', JPATH_SITE );
and
$otherparams =& JComponentHelper::getParams( 'com_othercomponent' );
??
$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.
http://biziant.com - Open Joomla Firewall/IDS
Unsolicited private messages/emails = hire me to fix your problem.
καλλιστι
- ljk
- 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?
Hello,
Thank you for your help.
Next question, how do I access the component parameters. I tried:
and this is what is in config.xml for com_posuid:
So, I expected that I would get 5 returned, but I am getting nothing returned.
I really appreciate you help.
Thank you.
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');
Code: Select all
<param type="text" name="e-commerce-detail6" label="Shopper Group ID" default="5" description="default: 5" class="" cols="3" rows="1"/>
I really appreciate you help.
Thank you.
-
- Joomla! Ace
- Posts: 1964
- Joined: Tue Jun 09, 2009 2:21 am
- Location: WV
- Contact:
Re: Loading language file & parameters from another component?
Have you tried defining a default in your return?
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 ).
Code: Select all
$pos_params = & JComponentHelper::getParams('com_posuid');
return $pos_params->get('e-commerce-detail6', 5);
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.
http://biziant.com - Open Joomla Firewall/IDS
Unsolicited private messages/emails = hire me to fix your problem.
καλλιστι
- ljk
- 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?
Hello,
Once again thank you for your help.
I figured out why I wasn't getting anything returned using:
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:
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.
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');
I continue reading the documentation for parameters and it has this statement:
on this page: http://docs.joomla.org/Component_parameters.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.
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.