+ Start a Discussion
incuGuSincuGuS 

URL Rewriting and URLFOR issue when pages need to be dynamic

Hello Guys and Girls,

 

 

When implementing URL Rewriting on a site with Ideas Base Theme (IBT) i found a problem that i haven't been able to work around.

The issue comes from the need of having links with dynamic page references, since the IBT uses pages overrides to customize the site.

When using Page References, Page Urls, String or any other form(except $Page.myPageName) the URLFOR does not convert to the Nice URL.

 

 

A bit of background:

 

The IBT uses a Site configuration object to hold in its records the information about a site using it, one of its options is to OVERRIDE the default pages for the site, for example IdeasPageList, which is the one handling the listing of ideas and browsing through categories, etc.

 

This field in the Site Config record takes a String, which is the name of the Page you want IdeasPageList to be overriden with.

Therefore i cannot use the $page.mypageName for the URLFOR since the Page to be used is Dynamic.

 

 

Tried >

 

 

public PageRefence IdeaListPage {get;set;}

 

 

<apex:outputLink value="{!URLFOR($Page.ideaList)}">All Ideas</apex:outputLink>

<apex:outputLink value="{!URLFOR(IdeaListPage.url)}">All Ideas</apex:outputLink>

<apex:outputLink value="{!IdeaListPage}">All Ideas</apex:outputLink

 

Result is >

 

 

https://mysite.force.com/sitename/all

https://mysite.force.com/sitename/ideaList

https://mysite.force.com/sitename/ideaList

 

Only the first one is Rewritten, because it uses the static $page.mypagename , and in order to make the Url Rewriting work for any site using IBT and work if the IdeaListPage is changed i need a way to make the Url Rewriting work either passing a Url String, or a Page reference, not only the $page.mypagename way.

 

 

So any ideas?  (no pun intended :P )

 

 

Thanks in advance,

Gaston!

 

 

Aaron FiskeAaron Fiske

The rewriter should trigger on any String passed into URLFOR, not just a $Page reference. It will also rewrite explicitly created PageReferences.

 

What it will not rewrite are absolute URLs. If If IdeaListPage is coming out as absolute, that could be the problem. (The URLFOR($Page) one operates on a relative url, then makes it absolute). You could try trimming/substringing off the server address, that should fix things for you. Maybe add a wrapper method of your own around getIdeaListPage?

 

Aaron