New module tutorial

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Locked
scooper
Forum Members
Forum Members
Posts: 242
Joined: Fri Dec 09, 2005 12:36 pm
Location: Marlow, UK

New module tutorial

Post by scooper »

So, first of all, huge thanks to Calguy and everyone involved in the production of the
new module writing tutorial.

I'm sure it will be fantastically useful to everyone who wants to develop modules and I've been using it already.

I have come across my first bug in it though - so do we have a preferred way of feeding back issues?
Is there a bug tracker or should we just post any feedback in the forum?

Assuming the latter, I reckon the lines for adding words to the search module on page 39

Code: Select all

$search = \cms_utils::get_search_module();
if( is_object($module) ) {
    if( !$holiday->published ) {
        $search->DeleteWords($this->GetName(), $holiday->id, 'holiday');
    } else {
        $search->AddWords($this->GetName(), $holiday->id, 'holiday', $holiday->name.' 
'.strip_tags($holiday->description));
    }
}
have an incorrect variable $module and should begin

Code: Select all

$search = \cms_utils::get_search_module();
if( is_object($search) ) {
....
Well done everyone though - it's definitely a great document and much appreciated.

s.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: New module tutorial

Post by calguy1000 »

Thanks for catching that.

I will upload a new version shortly. perhaps this weekend with that minor correction.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
DavidJessurun

Re: New module tutorial

Post by DavidJessurun »

I noticed example code omitted the closing ?>

Is this a convention I'm unaware of, or is there a reason for this?
scooper
Forum Members
Forum Members
Posts: 242
Joined: Fri Dec 09, 2005 12:36 pm
Location: Marlow, UK

Re: New module tutorial

Post by scooper »

Yep - it's good practice if it's the end of the file to omit the closing tag to avoid the possibility of whitespace or line breaks sneaking in.

https://secure.php.net/manual/en/langua ... hptags.php says:
If a file is pure PHP code, it is preferable to omit the PHP closing tag at the end of the file. This prevents accidental whitespace or new lines being added after the PHP closing tag, which may cause unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script.
DavidJessurun

Re: New module tutorial

Post by DavidJessurun »

Nice, thanks. Never knew that. :)
Locked

Return to “Developers Discussion”