21293 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 786 Views |
-
location of function

16 February 2011 at 1:13pm
Hi I'm new to SS.
I have many contact forms at different pages and using same function.
I don't want to write same function on every controller.
Where I can put the function that all controller can access to it?
Thanks
-
Re: location of function

16 February 2011 at 5:28pm
Put it in code/Page.php under Page_Controller. As long as your contact form pages extend the Page class, they will inherit your function.
-
Re: location of function

17 February 2011 at 9:47am
Thanks Ryan M,
Could you show me example, accessing controller B to Page_Controller ?
-
Re: location of function

17 February 2011 at 12:45pm
I'm not sure what you mean... do you want me to write an example of how to call the function from another page?
All you would need to do is either use this in your page's controller:
$this->yourCustomFunction();
or in your template:
$yourCustomFunction
Remember, putting the function in the parent, ie Page.php, will make it available to any pages that extend Page.php.
| 786 Views | ||
|
Page:
1
|
Go to Top |


