Page 1 of 1

New module tutorial

Posted: Fri Nov 13, 2015 4:34 pm
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.

Re: New module tutorial

Posted: Fri Nov 13, 2015 5:17 pm
by calguy1000
Thanks for catching that.

I will upload a new version shortly. perhaps this weekend with that minor correction.

Re: New module tutorial

Posted: Thu Dec 03, 2015 2:22 pm
by DavidJessurun
I noticed example code omitted the closing ?>

Is this a convention I'm unaware of, or is there a reason for this?

Re: New module tutorial

Posted: Thu Dec 03, 2015 8:24 pm
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.

Re: New module tutorial

Posted: Thu Dec 03, 2015 9:05 pm
by DavidJessurun
Nice, thanks. Never knew that. :)