Module Development for Beginner

trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Thu, 2006-02-23 05:10

Hi I am a newbie in module development and I want to develop one.. Can anyone help me develop a module that logs every URL of every site I am visiting? Thanks in advance..

 
ckdake
ckdake's picture

Joined: 2004-02-18
Posts: 2258
Posted: Sun, 2006-02-26 18:54

Take a look at an existing module and see how it works, when you have specific questions we can help you out.

--
http://ckdake.com/

If you found my help useful, please consider donating to Gallery.

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Mon, 2006-02-27 02:41

Thanks for the reply. How do these existing gallery module handle event? What specific topic must I need to review in order to do this project. Thanks.

 
ckdake
ckdake's picture

Joined: 2004-02-18
Posts: 2258
Posted: Mon, 2006-02-27 04:44

Why type of event? What types of specific topics?

--
http://ckdake.com/

If you found my help useful, please consider donating to Gallery.

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Mon, 2006-02-27 05:16

An event listener that logs the URL whenver I browse the gallery. Do I need to review the Gallery Core classes? How can I use these existing module for my project.. Thanks a lot.

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Mon, 2006-02-27 05:19

browse the web I mean.. I have read the handleEvent method of the Gallery Core.. what does this method do or the class itself, how does it function.

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Mon, 2006-02-27 06:28

I have figured it out.. Does the any of the Gallery Core classes have an API for creating a text file and writing to it?

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Mon, 2006-02-27 11:38

How can I log these URL's in a text file? Please help

 
ckdake
ckdake's picture

Joined: 2004-02-18
Posts: 2258
Posted: Mon, 2006-02-27 21:31

It's probably smarter to log them in the database. The rating module creates a table so you could take a look at that for an example.

If you won't be redistributing your changes, just hard coding in an fopen fwrite fclose is probably alright. There is no API for logging text to a file.

--
http://ckdake.com/

If you found my help useful, please consider donating to Gallery.

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Tue, 2006-02-28 10:07

Thanks.. What is the role of the handleEvent function of a module?!

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Tue, 2006-02-28 10:55

The Gallery dont seems to trigger my handlEvennt function.. What you think must be the problem?

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Tue, 2006-02-28 13:11

I cant execute the fwrite function.. please help..

 
ckdake
ckdake's picture

Joined: 2004-02-18
Posts: 2258
Posted: Tue, 2006-02-28 14:56

You registered your handleEvent function only for the GalleryEntity::save event. Try editing an item and see if that shows up in the log.

--
http://ckdake.com/

If you found my help useful, please consider donating to Gallery.

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Tue, 2006-02-28 15:12

What event must I register in order to trigger the event while I am browsing in and out of the album? Thank you very much.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2006-02-28 21:14

facts:
- there's no event that is triggered when loading / showing a page.
- there is e.g. an event for when ever an entity is saved
- there are on load handlers (not the same as events) for all entities

not all pages served by G2 are associated with an entity / item (album, image, ..). but most are and those you care about are definitely associated with an entity.

your options:
- i guess you'll want either to register a onload handler for all entities in G2, IMO a bad idea.
- or request that we add an event for page load or something like that (or just hack your g2 if you don't want to publish your module)
- or wait until we add a feature like onPageLoad to g2, which is definitely planned. right now, we only allow for album, photo and sidebar blocks. you can't have blocks / preloads that are loaded on each page load. so we plan to add something like that anyway, but maybe just in a few months.

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Wed, 2006-03-01 02:25

How can I add an event for page load? What do you mean "just hack your g2"? Does it mean I must edit a Gallery core class? What class is it? Thanks.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2006-03-01 05:02

yes, if you follow this route you have to edit the core module.
i guess you could just add a GalleryCoreApi::postEvent() call in main.php.

grep for postEvent to find examples.

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Wed, 2006-03-01 08:21

Oh thanks. Your reply is a great help. Another question.. What basically must I do in order to register a new Event which in my case in the onLoad page.

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Wed, 2006-03-01 08:29

The onPageLoad event is the only thing that is lacking in my module. Can you please give us the first release of these event so that we can implement and publish the module I am developing? Please help. Thanks in advance.

 
ckdake
ckdake's picture

Joined: 2004-02-18
Posts: 2258
Posted: Fri, 2006-03-03 01:23

Look around for postEvent in the code and use that as an example. Just add a postEvent call in main.php like valiant suggested.

--
http://ckdake.com/

If you found my help useful, please consider donating to Gallery.

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Tue, 2006-03-07 07:24

OS - Mandrake Linux
MySQL - MySQL4.1
Apache - 2.0
PHP - 4

How can I add a GalleryCoreApi::postEvent() call in main.php?

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Tue, 2006-03-07 11:18

Ala eh, galing naman! This gallery is great.. I have already log these URL's but another problem occurs. It does not work when I use embede mode. How can I solve these problem? Is it really impossible for an embeded mode gallery to trigger postEvent directly from xxxx.php? What must I do to solve this?

 
ckdake
ckdake's picture

Joined: 2004-02-18
Posts: 2258
Posted: Wed, 2006-03-08 02:30

You'll need the post event in embed.php as well is my guess..

--
http://ckdake.com/

If you found my help useful, please consider donating to Gallery.

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Wed, 2006-03-08 14:21

Thanks for all the replies. I've finally finished this project. The Gallery is so great.

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Wed, 2006-03-08 18:13

Care to share?
______________________
I made a theme for G2, try it :)

 
trowa barton
trowa barton's picture

Joined: 2006-02-23
Posts: 27
Posted: Thu, 2006-03-09 04:29

Well, this project seem so impossible for me when I am starting. But now, I figured out that it's just a matter of "taking it from the expert (valiant and ckdake)".
All you have to do is post an event in the main.php file (start.php in my case because I am on embeded mode) and then create the module that will listen to the event I created and logs those URLs.

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Thu, 2006-03-09 06:50

I meant the URL log module.

But a short step by step guide on what to do is not so bad either, I am sura that'll help a lot of people. 
______________________
I made a theme for G2, try it :)