1

I've successfully added alttemplate's for mobile pages, in regards to templates without a masterpage. When it comes to using masterpages I'm lost with setting the necessary URL's.

Example:

Home
Masterpage
  > About
  > Contact

mHome
mMasterpage
  > mAbout
  > mContact

So I'd be creating a custom masterpage with the about and contact inheriting the template. I can get the mHome to redirect on mobile using:

document.location.href = '?altTemplate=mHome';

Now when it comes to redirecting the About to mAbout and Contact to mContact how would this differentiate?

I'd assume (but it doesn't work):

document.location.href = 'About?altTemplate=mAbout';

Regards.

Robert Foster
  • 2,317
  • 18
  • 28
thatguy
  • 99
  • 1
  • 11
  • What kind of error are you getting when you try the About page with it's alternate template? And does the About page have the mobile template assigned to it's `DocumentType`? – Robert Foster Oct 16 '15 at 01:40
  • Yes it's assigned to the DocumentType, I'm getting a page not found error: No template exists to render the document at url '/About?altTemplate=mAbout' – thatguy Oct 16 '15 at 14:07

2 Answers2

0

The only reason you'll get a message "no template exists" is because either there is no template available, or sometimes the cache needs refreshing.

Eliminate the latter first by deleting the umbraco.config file from App_Data folder so another is created (assuming you haven't turned off the cache file). Now also check that your document type for the About page can actually use the mAbout template (that you've allowed it). To do this, try changing the default template of the About to use the mAbout template. If this works then check your case-sensitive template alias is being requested by the URL.

If all this fails, I suggest updating your question to include the log file (in the /App_Data/Logs folder) output of your page request. I suggest deleting the log file and then refreshing your page to create a fresh instance.

csharpforevermore
  • 1,472
  • 15
  • 27
-1

I think you might be able to use the following path format:

document.location.href = '/About/mAbout.aspx';

If that still returns a 404, perhaps there is something custom in your UrlRewriting that breaks those paths?

James Green
  • 1,827
  • 1
  • 13
  • 13
  • That's completely wrong. There's nothing in his content structure to suggest his mobile About page (mAbout) is a child of the About page. – csharpforevermore Nov 06 '15 at 19:36
  • When you say 'That's completely wrong' @ForTheWatch, I think you mean to say 'I didn't know Umbraco worked that way'. My answer does not concern itself with his content structure at all, rather the templates allowed to be rendered on the node. Read the source in Umbraco.Web/Routing/ContentFinderByNiceUrlAndTemplate.cs (& the test case in ContentFinderByNiceUrlAndTemplateTests.cs) - the name of an allowed altTemplate can be appended to the Url as a path. It has been this way since U3 iirc. I fail to see why that makes my original answer unhelpful but.... – James Green Nov 07 '15 at 00:01