Welcome Guest, Not a member yet? Register   Sign In
View functions accessing viewdata
#1

[eluser]Unknown[/eluser]
In my view, I am trying to keep things simple by writing some functions to do some common things.

I have something like this, where $viewdata[sortcurrent] is passed from my controller:

Code:
function sorted_by( $sortnumber, $displaytext ) {
   if ( $sortnumber == $sortcurrent ) {
   ...
   }
}

Even if I add global $sortcurrent, I still can't seem to access that variable from the function contained in my view. (It isn't exactly a global, but it is local in scope.)

To work around this, I ended up using:
Code:
function sorted_by( $sortnumber, $displaytext, $sortcurrent )

and everywhere sorted_by is called, I pass in $sortcurrent. This works, but is there a better or easier way to access the $sortcurrent from inside a function?


Messages In This Thread
View functions accessing viewdata - by El Forum - 09-23-2009, 11:24 AM
View functions accessing viewdata - by El Forum - 09-23-2009, 10:51 PM
View functions accessing viewdata - by El Forum - 09-24-2009, 01:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB