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, Ed, biapar, Willr, Ingo, swaiba

currentPageID() for unique names?

Go to End

2 Posts   1456 Views


Community Member, 135 Posts

18 February 2009 at 1:39pm

Edited: 18/02/2009 1:45pm

I am trying to use currentPageID() in a widget I am building, in order for the widget to be installed on several different pages (without having to manually set a unique id). I thought that currentPageID() would do the job, however, I cant get it to work.

Here is the code in question

function pageID() {
		return currentPageID();

I am obviously using this wrong, but I cant find any examples of it being used. Is there an easier way to have a unique page id?


Community Member, 55 Posts

14 May 2009 at 1:50pm

I have no idea about writing widgets, so this might be totally unhelpful, but...

can you just use $this->ID (in the code) or $ID in the template.

And in your code, shouldn't it be $this->currentPageID() ?