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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Outputting URL value in template


Reply


2 Posts   310 Views

Avatar
Fraser

Community Member, 47 Posts

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

Avatar
Fraser

Community Member, 47 Posts

31 May 2012 at 11:19am

Edited: 31/05/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?