Web Tool Bag  
Home · Articles · Downloads · Discussion Forum · Web Links · News CategoriesFebruary 05 2012 09:59:39
Navigation
Home
Articles
Downloads
Discussion Forum
Web Links
News Categories
Search
Users Online
Guests Online: 5
No Members Online

Registered Members: 625
Newest Member: nownigcheencex43
Forum Threads
Newest Threads
reverse mortgage
Science channels in ...
How can I see the fu...
Order Flagyl Without...
X-Rumer 7.0 - best s...
Hottest Threads
Installation [11]
Hermoine nude [6]
Captcha picture d... [6]
Integrate with Vi... [5]
Any questions and... [5]
Trusted web hosting

Coupon Code
WEBTOOLBAG
Latest Articles
jQuery Accordion - m...
Few Guidelines for W...
Move OST to PST to U...
Microsoft OST vs. Mi...
Tips for Specialized...
Gallery 2 Module Development
Article about development of plugins and modules for Gallery 2.

Welcome to this Gallery2 Module Development tutorial.

The reason why i'll make this tutorial is because i personaly had trouble learning how to make custom modules.
I hope to make things more clear to you, so we'll find more tutorials online. :)

You will most likeley find some wrong phrases or grammer in this text, for english is not my native language.

Lets cut the talk, and i will explain some basics about modules, and how gallery2 works. (note that i will use G2 as a abbreviation for Gallery2)

How dous Gallery2 work?

- How the code lookes like
The thing what is very striking, is that G2 is Object Orientated. This basicly means you will be trown in quite some classes and methods.
You dont need to understand OOP (Object Orientated Programming) to make G2 Modules. It may be more easy to understand the code when you have some experience in OOP though.

- Storing data
Data can be stored in various ways.. Parameters, Maps and Entities. We'll start with parameters, for they are quite handy for storing a few values. With this, think about some text for a module, that you want to edit easily. Or maybe an email adress for a contact module?
But be carefull to not to store to much in your Parameter Map. When you'll build something like a guestbook, you dont want to use the Parameters. The parameter table is just one table, that contacts a few values of all modules. You dont want to fill the table with hundereds of entries of just one module.
When you will create something as big as a guestbook, you will choose for a map or entitie.

- How to controll the look of your module
G2 works with a Template Parser (Smarty). This means that you seperate your code from the layout. This is much cleaner, you will understand more about these templates when we'll start making a page.

- How your module is connected to G2
All of your actions are controlled via the API, this a sort of link between your module, and the core.


Make the base of the module!

Ok lets start with building our base. I will first show you the code, and after that we'll break the code, and handle each line.

CODE

Code:

1
<?php
2

3
/*
4
 * Gallery - a web based photo album viewer and editor
5
 * Copyright (C) 2000-2006 Bharat Mediratta
6
 *
7
 * This program is free software; you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation; either version 2 of the License, or (at
10
 * your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful, but
13
 * WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
20
 */

21

22
/*
23
 * Jim's test module (the name)
24
 *
25
 * A module to show you how the base works. (a more wide description)
26
 *
27
 * @package Jimsmodule (package name)
28
 * @author Jim Bokhove <your@email.com>
29
 * @version $Revision$ $Date: 2006/11/24 22:43:00 $
30
 */

31

32
class JimsModule extends GalleryModule {
33

34

35
    
function JimsModule() {
36
        
global $gallery;
37

38
        $this
->setId('jimsmodule');
39
        $this
->setName($gallery->i18n('Jims Module'));
40
        $this
->setDescription($gallery->i18n('Description? Well, this shows you the base.'));
41
        $this
->setVersion('0.0.1');
42
        $this
->setGroup('newgroup'$gallery->i18n('New Group'));
43
        $this
->setCallbacks('');
44
        $this
->setRequiredCoreApi(array(710));
45
        $this
->setRequiredModuleApi(array(32));
46
    
}
47

48
}
49

50

51
?>



- Eplained
First we need to define we're writing PHP code with
Followed by a block which contains Copyrights, license etc.

Now, you'll see a comment block with some info of your module. Just fill the lines with your own names, description etc.

After this is done, you will see the real deal. Starting some real code! "class JimsModule extends GalleryModule {" defines the name of the module. And also let G2 this is a module. You may only change the second word, and fill in your own. Dont change the GalleryModule name or something.

Ok, we have ourselves a start, now define the function of the class (OOP stuff, dont need to understand why..). WARNING: The function name, must be 100% the same as your class name! So when your classname is in this case JimsModule, your function also needs to be named JimsModule.

"global $gallery" grabs a variable from the system. We'll go further in this later.

Okay, now you'll see a few lines. These lines defines the name, description, version, etc etc.

Lets start with: $this->setId('jimsmodule');
Just fill in a clean name like above, no uppercase.

$this->setName($gallery->i18n('Jims Module'));
Defines a clean name, this is the name you will read in G2.

$this->setDescription($gallery->i18n('Description? Well, this shows you the base.'));
Description of your module.. No explenation needed right? :)

$this->setVersion('0.0.1');
The version of your script. Update this when you make a change on your module, this can be very handy, en ofcourse.. It is needed. :)

$this->setGroup('newgroup', $gallery->i18n('New Group'));
This defines the group. The group is where you will find your module listed in the admin panel. I used New Group to be more clear, but recommend to use an existing group. (just grab a group from the module page, which you think suits your module best.)

$this->setCallbacks('');
We'll come back to this line, it is not needed to fill in. But it comes with very nice feathures.

$this->setRequiredCoreApi(array(7, 10));
$this->setRequiredModuleApi(array(3, 2));
These are vesions of API's. This exists so you wont get problems when you import an old or new module, that dousn't work with your current G2 install. If you dont know what version you have, just grab a module from the galler2/modules/ directory. And open that module.inc file to check what the have.

And to end this, close your function and class with a }. And ofcourse we close the PHP script with ?>.

Save this file as module.inc

Now make a folder that contains the name of the module. ($this->setId('jimsmodule'); < this name)

Copy module.inc into the folder, and upload the folder to your gallery2/modules/ directory.

Now simply open your admin panel, go to the modules page. And you can activate your module. Next time we'll make a static page that uses a template.

http://www.combined-minds.net/

Posted by zdravko on December 10 2007 15:47:28 2 Comments · 1425 Reads · Print
Comments
Emilya on September 30 2011 05:39:28
fake rolex watches ceremony pictures has turn out to be essentially the most crucial inside the current make any difference iwc classic replica , probably the most stunning moments of lifestyle to retain and never patek phillipe replica australia replicawatches , as grandmother employed to her father's age, married exactly the same day a significant team of people today crowded the gallery, awaiting new formal pictures are moments Increase the regular of dwelling these days rolex fake watches , marriage ceremony photography growing market competitors and led towards the advancement of the large assortment of marriage ceremony photography, not simply have a tendency to diversify when it comes to digital camera efficiency in solutions, marriage ceremony photography each much more unique and pure marriage ceremony images or lease a mixture with the key mode of operation gown marriage ceremony photography market nowadays, rolex fake the ask
Emilya on October 17 2011 07:24:38
accoutrement andwork chirstian , The proper option will be the gown with spaghetti straps and many sorts of sleeves.Wholesale red bottom shoes . The Jasmine Assortment has the newest and widest choice of designs and styles which you can attempt out , louboutins Low cost Bridesmaid Attire.a000ƒ9Google Applications computer software engineer Will Smit,bridesmaid.a000ƒ9 states Google Maps company item supervisor Jarda Bengl, christian sale Junior bridesmaid would generally need to appear fashionable and gown inside a gown or outfit that can flatter their attractiveness and also appeal to their age array.in addition. aged amongst 8 to fourteen, shoes with red bottom Google exposed its new person coverage administration permitting admins section their customers into organizational models and manage which applications are enabled or disabled for
Post Comment
Please Login to Post a Comment.
Ratings
Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Member Poll
Which PHP framework do you preffer?

Symfony

Zend

PHPDevShell

PHP on TRAX

eZ Components

Fusebox

PhpOpenbiz

Prado

QPHP

Seagull

You must login to vote.
Shoutbox
You must login to post a message.

Vince
03/10/2011 18:17
Hi, How to remove Register from Login screen? I don't want them to register and have full access! if you leave register then they should not have any rights until the admin assigns them

webtoolz
26/09/2011 08:28
Please describe your problem with more details. Thank you.

bimmer98
22/11/2010 18:31
Help. There was a problem with the request; error regarding feedbackzdr form program

PHP Obfuscator
Copyright © 2012 - www.webtoolbag.com