21285 Posts in 5732 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 147 Views |
-
Outputting URL value in template

31 May 2012 at 10:53am
Probably a very simple one......
I have a dataobject which is returning a calendar page
public function calendar($request) {
$page = DataObject::get('SiteTree','"SiteTree"."ID" =' . $this->ID);
return $this->customise(array("resort"=>$page))->renderwith(array('CalendarPage','Page'));
}I am linking to the calendar as such:
/[region-name]/[resort-name]/calendar/55
Where 55 (in this case) is the ID of a product relating to a resort. I need to get this value (in this case 55) into the data-id of a div in my calendar template as my jQuery calendar uses this to fetch some jSON to display events on a calendar.
How can I do this?
Thanks
-
Re: Outputting URL value in template

31 May 2012 at 11:19am Last edited: 31 May 2012 11:27am
Got it.
public function calendar($request) {
//$productID = Director::urlParam('id');
//$productID = 'adfasdf';
$page = DataObject::get('SiteTree','"SiteTree"."ID" =' . $this->ID);
return $this->customise(array("resort"=>$page))->renderwith(array('CalendarPage','Page'));
}
public function ProductID(){
$URLParams = Director::URLParams();
$Action = $URLParams['OtherID'];
return($Action);
}and then call it in the template with $ProductID
Is this the correct way of doing this or is there a more efficient way?
| 147 Views | ||
|
Page:
1
|
Go to Top |

