Help with plugin creation

Help with plugin creation, a forum discussion on Jojo CMS. Join us for more discussions on Help with plugin creation on our Plugin Support forum.

Back to Forum Index : Back to Plugin Support   RSS
glouk glouk

31 May 2008
Posts: 46

Hi,

I'm trying to build a plugin that will be a front end to my data structure, and i really need some insight there.

I've been studying several plugins and here is what i figured out :

- myplug.php : contains the main class with functions

- api.php : unclear to me

- global.php : ??

- actions/action.php : no idea

- templates/myplug.tpl : smarty template (easy one)

- setup.php and uninstall.php : those are ok

that's not much... What are those files for ? when are they called ? How ?

I got to have my plugin listed in the technical tab of the page editor, but i'm not sure how... i think it's thanks to this line i put in api.php :
$_provides['pluginClasses'] = array(
'Jojo_Plugin_glouk_demo' => 'demo G L O U K',
);
is that it ?

I saw the functions in the main class but never found where or how they were called, so i figured the _getContent() function is supposed to be executed automatically and returns an array :
$content['content'] is the main content, and other elements may override settings in the page admin.

I'm not very familiar with classes and OOP, but it seems to me a little step by step plugin creation tutorial would be beneficial...

Also, the Util class seems to have useful functions, but it's not documented anywhere
Harvey

Core Developer

Harvey

31 May 2008
Posts: 327

Sorry, only have time for a quick reply...

api.php - is where you define hooks and filters for the plugin. Jojo, like Wordpress and others, has hook points inserted in useful parts of the core code. Your plugin can add code to these hook points using the Jojo::addhook() function, which happens in api.php - a hook simply runs a custom function at a certian point of the code execution. We have a good page on how filters work in the docs.

global.php - runs near the top of the script execution. Use this is you need some custom code run on every page. Typically, this is used for assigning smarty vars that are needed in the template.

actions - these are relating to FRAJAX which is a custom AJAX library Jojo uses. This is being phased out, we are slowly converting to using JSON and jQuery instead.

The $_provides line is the plugins way of telling Jojo about a new page type. I think this is also documented.

api.php is also used for adding Options into Jojo. See pretty much any plugin for an example. You can then use Jojo::getOption('option_name', 'default value') to read an option in PHP, or {$OPTIONS.option_name} in Smarty.

Util is part of the Horde framework. The comments in the class do a good job of explaining what it does, otherwise the Horde framework has good docs also.

_getContent is the function which is called for plugins that create a new page type (such as FAQ). This overrides the function in the Jojo plugin class. The function can return an array with the following elements...

content
title
seotitle
css
javascript
head
index
followto
followfrom
feedicon
and others

Setting these changes the way the page looks / behaves, and if you leave anything blank it populates from 'edit pages' instead.

Sorry I don't have time for a more complete answer right now, but hopefully that clears up the biggies.

Harvey.
glouk glouk

31 May 2008
Posts: 46

Thank you harvey,

things begin to clear up a bit...

today's new problem is : with nice urls all over the place, how do i pass key parameters like id ?

i'm sure this one is a silly one, but however...

And also, i'd like to build a left side tree menu that would look somewhat like ajax tree list in the admin, is there a quick way to achieve this using jojo's libs ? (javascript is not exactly my cup of tea ;))
Harvey

Core Developer

Harvey

1 Jun 2008
Posts: 327

We use a class I wrote called HKtree for making the sitemap. It produces a regular HTML bullet list and is easy enough to use. You then need to apply 3rd party Javascript or CSS to get fancy effects etc.

The one we use in the admin section I personally can't offer much support on, as I didn't implement that code (I can get another team member to get in touch during business hours). But I do know it's based on EXTJS which is a Javascript library, and it's pretty large - I wouldn't use it on a public facing page for this reason alone.

There are plenty of open source tree menus out there, you want one that is lightweight, works of a standard bullet list, and being jQuery based would be a bonus as Jojo already has jQuery loaded.

Unfortunately, I can't recommend anything at this stage.
Back to Forum Index : Back to Plugin Support   RSS
You must be logged in to post a reply



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