How to change the canonical path?

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
3/26/2012 9:45:09 PM
Gravatar
Total Posts 39

How to change the canonical path?

 

In a custom module that I built the client wants to use AddThis for social media shares. AddThis looks at the canonical link for the URL but the canonical links is not correct.  The module that I build uses mojoportal Friendly URLs

The version of mojoportal that I am using is:  2.3.3.9 MSSQL

Example page: http://www.buffed.org.au/buffed-news-the-buffington-post-february-2012.aspx

When you view source you can see that canonical link is not the friendly URL.

<link rel='canonical' href='http://www.buffed.org.au/buffed-news.aspx' />

 

Any advice appreciated.

3/27/2012 1:07:30 PM
Gravatar
Total Posts 18439

Re: How to change the canonical path?

mojoPortal does not add canonical links in your custom feature supporting pages, it only adds them in CMS pages (ie the pages in the main menu) and in included features that have their own code for adding them, so that must be something in your own code doing that.

2.3.3.9 is also a very old version from early in 2010

3/27/2012 10:30:31 PM
Gravatar
Total Posts 39

Re: How to change the canonical path?

Sorry if I did not explain very well. This is not a supporting page. It is a top level page that is in the main menu

I have a custom module on the page, http://www.buffed.org.au/buffed-news.aspx

Like a blog, the module I built displays a list of short version of items or detailed view of one item. I have used Friendly URLs for the detailed view of an item

For the list view:

  • FriendlyUrl buffed-news.aspx
  • RealUrl ~/Default.aspx?pageid=231

For the detailed item view:

  • FriendlyUrl buffed-news-the-buffington-post-february-2012.aspx
  • RealUrl ~/Default.aspx?pageid=231&itemid=27

 

The canonical url is being set in the mojoportal Default page from within the LoadPage method

So the CurrentPage.Url is being used when I would want it to use the Friendly Url. I was thinking I might be able to set the CannonicalOverride value as I display the detailed view of the module

 

(thanks for the heads-up about the mojo portal version I am running I hope to schedule in some time to upgrade in a couple months)

3/28/2012 7:06:14 AM
Gravatar
Total Posts 18439

Re: How to change the canonical path?

Sorry but in my opinion that is the wrong way to do it, you should use a supporting page for a detail page as illustrated in all included features in mojoPortal that have detail links or use their own friendly urls. This problem is a good example of why this is not the right way to do it. Modules should be designed to play nice with other modules on the CMS page which means they don't own the page and should not manipulate the url of the CMS page with new parameters.

See the Blog feature, it has a list of posts on the cms page but individual posts link to a detail view that is not the CMS page, ie the friendly urls point to ~/Blog/BlogView.aspx?pageid=x&mid=y&ItemID=z not to ~/Default.aspx with extra params.

You are trying to re-use Default.aspx for things it was not intended for, it is the CMS page and it will use the canonical url of the current CMS page.

I recommend re-factor your feature to use a supporting page where you have complete control over the page and update your friendly urls to point to your supporting page.

Hope that helps,

Joe

3/28/2012 5:38:15 PM
Gravatar
Total Posts 39

Re: How to change the canonical path?

Thanks Joe. I agree with your suggestion.

I just focused on making the page work rather then making the best use of the framework. The module is live on a couple sites. But as you point out we only need to change what the friendly urls point to so the refactor will probably not be noticeable for the clients.

 

You must sign in to post in the forums. This thread is closed to new posts.