As I slowly learn how to create custom modules, I have run into problem I haven’t been able to figure out yet.
Let’s call my custom module Sports. In mod.sports.php I have my constructor function:
function Sports() { … }
and I can use it in templates just fine with {exp:sports} {sport_name} {/exp:sports}
but I want to create a new function called form. So I would expect to use it something like {exp:sports:form} {sport_name} {/exp:sports:form}.
I have the function declared:
function form() { … }
When I put {exp:sports:form} in my template, it recognizes it and doesn’t throw an error, but it doesn’t output anything either. It contains the exact same code as the Sports constructor function does.
What am I doing wrong here?
Thanks!
-chad
Alright, well I figured it out by looking around at some other custom modules. I’ll post my solution in case some other noob runs into this problem.
In the constructor function, there is no return value it just has something like this at the end of the function:
$this->return_data = str_replace(‘{sport_name}’,$query->row[‘sport_name’], $TMPL->tagdata);
So, I was using the same thing in my form() function. But what I needed to do was return the str_replace() result:
return str_replace(‘{sport_name}’,$query->row[‘sport_name’], $TMPL->tagdata);
On to the next issue…
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.