Glad you find my efforts useful.

On Tue, 2008-11-11 at 07:14 -0800, SRi wrote:
> That example made my day :) Thanks a lot for you effort! Can't get
> more descriptive than that! I'm sure newbies like me will definitely
> find it very useful.
> 
> Thanks once again.
> 
> On Nov 11, 7:42 pm, Benjamin Hutchins <[EMAIL PROTECTED]> wrote:
> > The API documentation is unfinished, which is probably why you missed
> > it. I had to find what I know about Habari by looking at it's core,
> > and what a sight it is.
> >
> > Let me attempt to explain how to make a basic plugin.
> >
> > (Also, sorry about a mistake I had. It is display_post not
> > display_entry. But continuing...)
> >
> > <?php
> >
> > // First you need to create a plugin class
> > class MyPlugin extends Plugin // always extend Plugin (for plugins)
> > {
> >
> >         /**
> >          * return information about your plugin, this is required
> >          */
> >         public function info()
> >         {
> >                 return array(
> >                         'name' => 'My Plugin',
> >                         'version' => '1.0',
> >                         'url' => 'http://myplugin.rockhabari.com', // url 
> > to some
> > information on your plugin
> >                         'author' =>  'Sir TeLebing',
> >                         'authorurl' => 'http://mysite.tld',
> >                         'license' => 'Apache License', // any license, try 
> > to be compatible
> > with Apache
> >                         'description' => 'My plugin rocks.' // what it does 
> > (a little more
> > descriptive than this)
> >                 );
> >         }
> >
> >         /* Now, it comes the hard part
> >          * Habari has two key features for using their API
> >          * One is an Action and is called when events happen.
> >          * The second is a Filter which is used to change information.
> >          *
> >          * Within a plugin you can specify functions with
> >          * action_ or filter_ in the begining of the function name
> >          * and if the
> >          */
> >
> >         /*
> >          * Filter "theme_act_display_post" is called when a post is viewed
> >          */
> >         public function filter_theme_act_display_post( $handled, $theme )
> >         {
> >                 // This is the Slug of the post being viewed.
> >                 $post_slug = $theme->matched_rule->named_arg_values['slug'];
> >
> >                 /**
> >                  * Now you can use that slug to go and find the
> >                  * Post ID using the Post::get() function like..
> >                  */
> >                 $post = Post::get(array('slug' => $slug));
> >
> >                 /**
> >                  * Now you have all the post information.
> >                  * $post->id will be the ID. You can use that
> >                  * for creating a statistics database.
> >                  */
> >
> >                 /**
> >                  * Also, in this case, you must return false
> >                  * If you return true, Habari will think that this Plugin
> >                  * Just handled the request and won't actually show the
> >                  * post.
> >                  */
> >                 return false;
> >         }
> >
> >         /**
> >          * Filter "theme_act_display_page" is called when a page is viewed
> >          */
> >         public function filter_theme_act_display_page( $handled, $theme )
> >         {
> >                 return false;
> >         }
> >
> > }
> >
> > On Nov 11, 8:29 am, SRi <[EMAIL PROTECTED]> wrote:
> >
> > > Thanks, but that kind of went over my head :( Can you recommend some
> > > example plugin which I can refer? And were can i find the
> > > display_entry, display_page, etc in the api documentation? Can't seem
> > > to find it (Shouldn't the api documentation have a search?
> >
> > > On Nov 10, 7:24 pm, Benjamin Hutchins <[EMAIL PROTECTED]> wrote:
> >
> > > > In this case it's an event. Questions like this might be best asked in
> > > > the IRC chat room, but it won't truly matter, someone will be around
> > > > to
> > > > help you.
> >
> > > > The action is display_entry.
> > > > Some other actions you might want to be aware of in your stat plugin
> > > > are:
> > > > display_entries (when browsing through multiple posts)
> > > > display_page (when looking at a page)
> > > > display_search (when running a search)
> > > > display_404 (when looking a 404 File Not Found error page)
> >
> > > > On Nov 10, 8:47 am, SRi <[EMAIL PROTECTED]> wrote:
> >
> > > > > On Nov 10, 4:20 pm, "Michael Harris" <[EMAIL PROTECTED]>
> > > > > wrote:
> >
> > > > > > 2008/11/10 SRi <[EMAIL PROTECTED]>:
> >
> > > > > > > Just moved to habari and I must say I'm really impressed.
> >
> > > > > > Welcome! Glad you're giving Habari a spin.
> >
> > > > > > > Thought I'd
> > > > > > > contribute my bit to the project. I'm planning to work on a simple
> > > > > > > stats plugin, which displays the number of hits per post, top 
> > > > > > > posts,
> > > > > > > etc. I've been through the wiki, but not able to decide where to
> > > > > > > start. If someone can point me in the right direction, I'll give 
> > > > > > > it a
> > > > > > > shot :)
> >
> > > > > > If you mean just a general place to start learning about creating 
> > > > > > plugins,
> > > > > > I'd suggesthttp://wiki.habariproject.org/en/Creating_A_Plugin. The 
> > > > > > best
> > > > > > other resources are the plugins in the -extras repo (have a look 
> > > > > > athttp://trac.habariproject.org/habari-extras), and the community 
> > > > > > on this
> > > > > > list for specific questions, and #habari IRC for a really good chat 
> > > > > > about
> > > > > > stuff.
> >
> > > > > > --
> > > > > > Michael C. Harris, School of CS&IT, RMIT 
> > > > > > Universityhttp://twofishcreative.com/michael/blog
> > > > > > IRC: michaeltwofish #habari
> >
> > > > > Thanks for those links. I've started to look around the API
> > > > > documentation to get a hold of things. Need one small clarification.
> > > > > What action/event occurs when a post/page is clicked (viewed by
> > > > > someone).
> > 


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/habari-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to