Page 1 of 1

How to develop plugins?

Posted: Fri Aug 17, 2007 9:06 pm
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

Re: How to develop plugins?

Posted: Fri Aug 17, 2007 10:34 pm
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

Posted: Sat Aug 18, 2007 2:08 am
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

Re: How to develop plugins?

Posted: Sat Aug 18, 2007 2:20 am
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

Posted: Sat Aug 18, 2007 2:49 am
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. :-)

Posted: Sat Aug 18, 2007 1:44 pm
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

Posted: Sat Aug 18, 2007 2:08 pm
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.