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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

urlParams from within DataObject


Go to End


2 Posts   1972 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')