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.

Data Model Questions /

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

Overriding the Link() method without eating my own face

Go to End

2 Posts   870 Views


Community Member, 21 Posts

25 April 2014 at 9:48am

Edited: 26/04/2014 4:24am

I'm trying to re-write the way a URL is constructed for a certain page type, but I'm having trouble figuring out the logic.

Say I have an address that looks like this:

Now, a category isn't Real Page, it's just a placeholder in the hierarchy to sort a section into smaller chunks. So the address I really want would look like . That would take me directly to the category part of the section page.

The problem I'm having is building the Link in a way that doesn't rely on the Link method itself. Maybe I'm not looking in the right place, but I'm having trouble piecing together exactly how to make this work. Any ideas?


Community Member, 21 Posts

26 April 2014 at 4:10am

Edited: 26/04/2014 4:24am

Nevermind, I figured it out. I've been away from SS for too long and was going about it all wrong. This does the trick:

public function Link() {
	$link = rtrim(parent::Link(), '/');
	$link = substr_replace($link, '/#', strrpos($link, '/'), 1);
	return $link;