Welcome Guest, Not a member yet? Register   Sign In
Calling a controller function from another function
#1

[eluser]weetstraw[/eluser]
Hello,

Question is:
Within the same controller, I often create cfunctions that are very similar. Usually I do this so the URL represents the content more accurately. Is it possible to have, lets call it, a template function that can be called throughout the controller?

Thanks!
#2

[eluser]BrianDHall[/eluser]
Sure:

Code:
function something()
{
}

function index()
{
   $this->something();
}

Pre-pend "_" as in "_something()" if you want the function to not be a page, just a function. If you want to use it in multiple controllers take a look at making your own helper or library.




Theme © iAndrew 2016 - Forum software by © MyBB