Universal Component Parameters

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Locked
orware
Joomla! Explorer
Joomla! Explorer
Posts: 255
Joined: Mon Jul 10, 2006 8:16 pm
Location: CA
Contact:

Universal Component Parameters

Post by orware » Wed Nov 05, 2008 11:32 pm

So I began work the other day on a component that would integrate with the Google Apps Provisioning API and there were a number of things I had to figure out.

The first was figuring out how to get the Gdata Library from the Zend Framework working as a Joomla Library plugin (not too difficult but there was a trick involving ini_set and adding the plugin's folder into the include path).

The other was figuring out how I could create a configuration page for the component so that I wouldn't have to hardcode the 3 inputs required to make a connection to the Google Apps API: the apps domain, the domain admin's email, and the domain admin's password.

At first I went with creating a config.xml file in the Joomla backend and was happy at how easy it was to get it working, and even though I didn't really need the capability for the global options to be overwritten in the menu items, I didn't really see it as a huge drawback.

In order to get an instance of the component parameters you would need to write the following line of code:

Code: Select all

$params =& $mainframe->getPageParameters('com_myextension');
However, the method above does not work in the Joomla backend because the getPageParameters method does not exist for the admin application. What this meant was that I really couldn't go about setting up the parameters using the normal config.xml method because the parameters were required for both the frontend (in order to create accounts) and the backend (also to create accounts or to modify the existing ones).

Instead what I decided to do was add the parameters to the plugin (since I needed to import the plugin anyway in order to include the Gdata Library) like this:

Code: Select all

$plugin =& JPluginHelper::getPlugin('gdata', 'gdata');
$params = new JParameter($plugin->params);
Which works perfectly for the frontend and the backend.

My only quibble is, was this a good way to solve the problem? And, is creating a separate plugin for configuration a good idea or a bad one?

Just wanted to share and get some feedback on this,

Thanks!

pbass98
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Thu Apr 03, 2008 3:26 am

Re: Universal Component Parameters

Post by pbass98 » Thu Nov 06, 2008 2:25 am

Hi Orware-- I've built a page that does a google base integration, but I'm having trouble getting it to work with Joomla 1.5 due to include path issues.

Can you please post some of your code and an explanation of what you did to get the zend loader working with Joomla (or the Jloader working with Zend classes, if that's what you did).

Thanks!

orware
Joomla! Explorer
Joomla! Explorer
Posts: 255
Joined: Mon Jul 10, 2006 8:16 pm
Location: CA
Contact:

Re: Universal Component Parameters

Post by orware » Thu Nov 06, 2008 3:07 am

pbass98,

I've attached a copy of my plugin as an example for you to use to compare, mainly the set_include_path call in the gdata.php file.

If you want to import the library into your component use the following (yours will probably be slightly different, of course):

Code: Select all

JPluginHelper::importPlugin('gdata', 'gdata');
gimport('Zend.Gdata.ClientLogin');
gimport('Zend.Gdata.Gapps');
And if you want to pull in parameters set in the plugin you'd do something like the following:
$plugin =& JPluginHelper::getPlugin('gdata', 'gdata');
$params = new JParameter($plugin->params);

$domain = $params->get('domain');
$domain_admin_email = echo $params->get('domain_admin_email');
$domain_admin_password = $params->get('domain_admin_password');

Also, don't forget to enable your plugin after installing or else you'll definitely run into errors,
You do not have the required permissions to view the files attached to this post.

pbass98
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Thu Apr 03, 2008 3:26 am

Re: Universal Component Parameters

Post by pbass98 » Thu Nov 06, 2008 4:09 am

Thank you very much! I'll let you know how it goes.


Locked

Return to “Joomla! 1.5 Coding”