How to develop plugins?

Creating and modifying plugins.
Post Reply
cgrauer
Regular
Posts: 18
Joined: Sat Aug 11, 2007 12:25 am
Location: Stuttgart (Germany)
Contact:

How to develop plugins?

Post by cgrauer »

How do you develop plugins? I miss some informations on that here (or I want for more serendipity ;-))

I want to create or just modify plugins for my own needs and I would like to know some basics to do this in compliance with the architecture of s9y and other plugins.

I already made some changes to a plugin (entrysplit). Is it common practice here to interchange such modifications (and if so: how?) I also would appreciate some survey for my modifications regarding the interfaces and standards of s9y...

Please forbear with me, I'm very new to s9y and also to developer communities etc (and even to php. I'm used to write Perl. Solitarily...). May be that I simply don't recognize the respective informations and features on this site...

Christian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: How to develop plugins?

Post by garvinhicking »

Hi!
cgrauer wrote:How do you develop plugins? I miss some informations on that here (or I want for more serendipity ;-))
What exactly do you mean? Did you look at the technical docs on www.s9y.org? We only have quite rough descriptions, that much is true. But it might change with the official s9y book being written. ;)

We also have some kind of coding guidlines here, even though it's a draft: http://www.s9y.org/217.html
I already made some changes to a plugin (entrysplit). Is it common practice here to interchange such modifications (and if so: how?) I also would appreciate some survey for my modifications regarding the interfaces and standards of s9y...
Yes, if you want to share your modifications with us, here on this forums is a good place to do so. :-)

So it's good of you to ask. We're not that strict on how things should be discussed, so actually you can simply go and talk about your modifications here. At least I will read it and try to comment. :)

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

Post by stm999999999 »

best information source is having a look into existing plugins :-)

And have a look at Best Practice / Coding Style
http://www.s9y.org/217.html
Ciao, Stephan
cgrauer
Regular
Posts: 18
Joined: Sat Aug 11, 2007 12:25 am
Location: Stuttgart (Germany)
Contact:

Re: How to develop plugins?

Post by cgrauer »

Yes, if you want to share your modifications with us, here on this forums is a good place to do so. :-)
Ok, it's only a small thing. Today I installed the entrysplit plugin since I had to publish a very long entry. But I wanted to have a table of contents on top of every subpage for a better navigation. So I modified the plugin and added an other config field for a markup string to identify the text for the toc item of each page and also a title for the whole thing.

You may download the files I changed at: http://www.christian-grauer.de/download ... ysplit.zip (is this ok? Or do you prefer to post the code to the forum?)

How about the lang-files? I found that some files endet with "?>", others not. Why?
And I have to admit that I don't speak Japanese and Turkish! Is this the end of my career as a s9y plugin designer? May I leave these files unchanged?

Christian
blog.brockha.us
Regular
Posts: 695
Joined: Tue Jul 03, 2007 3:34 am
Location: Berlin, Germany
Contact:

Post by blog.brockha.us »

If you add new entries to the language files, it is most important to add them to the en file. Because if an entry is not found in a language file, the entry is loaded from the default (the en) file. So no: It is not the end of your career as a s9y developer.. :-)

Others will add the missing entries in their language, if they need it. :-)
- Grischa Brockhaus - http://blog.brockha.us
- Want to make me happy? http://wishes.brockha.us/
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi Christian!

That's a quite good patch for your first one! I'd like to commit that to the official plugin! :)

I have two suggestions to make:

1. Please try to properly indent your code. Your new statements all where indented 4 spaces too many.

2. Try to make reasonable checks, if either the TOC is empty, or the $toc_title string. In that case,do not emit the HTML code for the TOC, as it would be useless and might corrupt the HTML rendering on the page. If there are no TOC elements, no <ul> should be shown, as an empty onewould be HTML invalid.

At last, the closing"?>" of a PHP file is always optional and not required by the PHP parser. If you omit it, you won't have problems when you have additional linebreaks at the end of your page. Otherwise you might get the dreaded "Headers are already sent" PHP error...

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
blog.brockha.us
Regular
Posts: 695
Joined: Tue Jul 03, 2007 3:34 am
Location: Berlin, Germany
Contact:

Post by blog.brockha.us »

So it's better to omit it, right? I always added it, if I see it missing, as I thought it was by mistake.
- Grischa Brockhaus - http://blog.brockha.us
- Want to make me happy? http://wishes.brockha.us/
Post Reply