3070 Posts in 869 Topics by 651 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 211 Views |
-
SS3 call a function from different DataObject

1 February 2013 at 10:16pm
Hi All
This may be simple but im just not sure
I have a dataobject extension that has a function with a query in it, i want to access that function from a different dataobject extension.
Can this be done? and how?Thanks
-
Re: SS3 call a function from different DataObject

2 February 2013 at 12:25am
Create it as a static function:
Class MyDataObject extends DataObject {
public static function foo() {
// Do some querying
}}
You can then call it by doing:
MyDataObject::foo()
-
Re: SS3 call a function from different DataObject

2 February 2013 at 9:33pm
Hi Kinglozzer
Thanks for your reply, when i made the function public static the wheels came off a bit and nothing worked.
although this gives me something to go on unfortunatly i have little time to explore this right now so i will plug away as i get time and try a few things and see what i get working
thanks again
voodoochile
-
Re: SS3 call a function from different DataObject

4 February 2013 at 8:05pm
If it's static you need to refer to the extension classname (e.g MyDataExtension::foo()). If your method is instance based you need to go $this->owner->foo().
-
Re: SS3 call a function from different DataObject

5 February 2013 at 10:35pm
Thanks Willr
I managed to work that bit out as in MyDataExtension::foo() and kind of got it working but not well, in the page view it returns a value for each object but dosn't seem to be running the query.
at this point i think i need to play around a little with this to get the result i am looking for.
| 211 Views | ||
|
Page:
1
|
Go to Top |



