Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

urlParams from within DataObject


Reply


2 Posts   1596 Views

Avatar
dio5

Community Member, 501 Posts

12 October 2007 at 10:50am

Hi guys,

I used to have a function Current() on my Category-class (extends DataObject):

function Current()
{
    if($_GET['Title'] == $this->Title) return " class='current'";
}

Now I rewrote some stuff so I don't have to use $_GET anymore, but use urlParams instead.
But the problem is, how do I call it from within my dataobject?

function Current()
{
    if(????->urlParams['ID'] == $this->Title) return " class='current'";
}

Any ideas?
(That's not the main function that uses the urlparams, but the other functions are on the pagecontrollers..)

Avatar
dio5

Community Member, 501 Posts

12 October 2007 at 11:27am

Fixed, thanks to MattSS.

Quite easy actually: when you're in a model instead of a controller you can access urlParams by

Director::urlParams() -> this gives an array of all them
or
Director::urlParam('the one you want')