plugin framework question(s)

Plugin framework question(s), a forum discussion on Jojo CMS. Join us for more discussions on Plugin framework question(s) on our General Discussion forum.

Back to Forum Index : Back to General Discussion   RSS
synfield

29 May 2008
Posts: 43

I'm trying to understand how plugins are constructed. I started with th emost basic 'hello world' plugin.

Could someone explain why you use

$_provides['JOJO_Plugin_Jojo_hello'] = array(
'Jojo_Plugin_404' => 'Hello - Hello Demo Page',
);

in the api.php page and why do you use Util::getFormData('name','') and not Jojo::getFormData('name',''). Taking a stab at it I assume that the class Util explodes the URI into an associative array? as opposed to an appended querystring using $_GET.

Where is the Util class & the $_provides array referenced and when do you need to use them/

Regards


Harvey

Core Developer

Harvey

29 May 2008
Posts: 327

Hi,

The reference to 404 is an error - someone obviously copy-pasted that code and forgot to edit it. It should read...

$_provides['Jojo_Plugin_Jojo_hello'] = array(
'Jojo_Plugin_Jojo_hello' => 'Hello - Hello Demo Page',
);

The Util:: is a reference to the Horde framework, it's a collection of handy functions we use quite a lot. We found ourselves using Util::getGormData all the time, so we incorporated the function into the Jojo class. Jojo::getFormData and Util::getFormData are identical, but we figured it was easier for new users to just use Jojo:: and not have to remember Util::.

getFormData is an easy way of getting access to GET or POST data. It will read POST in preference to GET, and the second argument is the default value you want to set. Being able to set a default prevents a tonne of PHP notice errors because of undefined variables.

Harvey.
synfield

1 Jun 2008
Posts: 43

Hi Harvey, Thanks for your reply.

>.. Jojo::getFormData and Util::getFormData are identical,..

I tried replacing $name = Util::getFormData('name',''); with Jojo::getFormData('name',''); but the plugin page goes blank, changing back to Util gets it working again?

For my own plugins will I have to use Util instead?

Regards.
Harvey

Core Developer

Harvey

1 Jun 2008
Posts: 327

Actually, that was a fairly recent change, sorry.

If you are using the beta, you will probably need to use the Util version. For RC1, you can use either.
synfield

1 Jun 2008
Posts: 43

I read in another forum post that $_provides array sets the page type? could you eloborate, as commenting this out in the "hello world" plugin doesn't make a difference, but i suspect that's not the case with a proper plugin.

This also leads to me to a question of ide, which would be suited to learning jojjo cms framework, i.e. do you have a recommended ide capable of variable inspection and line by line step through etc, that would facilitate the learning process.

Thanks once again.
glouk glouk

2 Jun 2008
Posts: 46

hi,

the $_provides array allows you to have your plugin listed in the technical tab of your page, thus providing link from the page to the plugin.

If it changed nothing when you commented it out, i guess it's because you did not clear the cache (admin page).

yes, things get cached even when cache is disabled, especially api.php ;)
Harvey

Core Developer

Harvey

2 Jun 2008
Posts: 327

Also, we have built in a certain amount of backwards compatibility with this feature so old versions of Jojo wouldn't break if people forgot to add the $_provides code. So commenting out the $_provides line may not result in any immediately visible breakages. However, we prefer you don't rely on this, as we do eventually remove backwards compatibility code.
raulandres

26 Sep 2009
Posts: 35

hello i replicate code from jojo_hello plugin into jojo_community for add the group on register step, but doesnt work. I configure api similar to jojohello-api.php (with code line of add URI) and inside the jojo_community_register.php insert 3 lines:


$groupname = Jojo::getFormData('groupname', '');
$smarty->assign('groupname', $groupname);

//add user to group
Jojo::insertQuery("INSERT INTO {usergroup_membership} (userid, groupid) VALUES (?, ?)",
array($userid,$groupname));

and i add {$groupname} at templates/jojo_community_register.tpl

But doesnt work, not work display on register form-template and not work de insert query because de row not appear the group on databse, after push register button.
what i forget? thx in advance harvey or another jojo forum member
r.

Back to Forum Index : Back to General Discussion   RSS
You must be logged in to post a reply



You need to Register or Log In before posting on these forums.