Jump to:

23372 Posts in 18174 Topics by 2865 members

General Questions

SilverStripe Forums » General Questions » currentPageID() for unique names?

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

Page: 1
Go to End
Author Topic: 1083 Views
  • grilldan
    Avatar
    Community Member
    135 Posts

    currentPageID() for unique names? Link to this post

    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?

  • david_nash
    Avatar
    Community Member
    55 Posts

    Re: currentPageID() for unique names? Link to this post

    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() ?

    1083 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.