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.

Archive /

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

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

Unique id for articles for Google News.


Reply


1481 Views

Avatar
ScottiouS

Community Member, 54 Posts

2 July 2007 at 1:53pm

Although I love the fact that Silverstripe creates SEF URL's I needed to include a unique ID for each article created by the system. This is pretty easy to do by just adding the following function into the ArticlePage.php under the ArticlePage class:

   function newLink() {
      return $this->Link() . '00' . $this->ID;
   }

You can now access the variable $newLink in the ArticleHolder.ss and the ArticlePage.ss which will point to your articles with an id number suffix.

Eg. and article that is normally at:
www.domain.com/my-first-blog/ with an ID of 5 will now link as:
www.domain.com/my-first-blog/005

There you now have the minimum 3 digit (length) unique ID required by Google News in each article URL.