I'm working on a Umbraco 6 website which has a page that displays some
YouTube videos. These videos can be nodes under the VideoPage node and can be
on nodes of a different type (Highlight).
The url structure is as follows: /videos/name-of-the-video.
This structure works for nodes under the VideoPage but not for the videos
that are on a Highlight.
So I created an class which implements the IContent interface and changed
the PublishedContent of the contentRequest object. This will render the
Highlight as is, and not the template of the VideoPage.
Can you change the template programmatically? I tried
contentRequest.SetTemplate, but the page went blank with the following
parameters:
Not sure I understand. What you describe seems possible but... when you do new Template(...) you do not retrieve an existing template, you just create an empty template that does not correspond to anything, hence the blank page. I guess what you really want is get the template that should already exist:
var template = ApplicationContext.Current.Services.FileService.GetTemplate("VideoPage");
If you don't set the template programmatically and you go to the url that the content finder handles you can also set the template by adding ?alttemplate=alias in the querystring. Even content finders support alt templates :-).
Setting a template IContentFinder
Hi there,
I'm working on a Umbraco 6 website which has a page that displays some YouTube videos. These videos can be nodes under the VideoPage node and can be on nodes of a different type (Highlight).
The url structure is as follows: /videos/name-of-the-video.
This structure works for nodes under the VideoPage but not for the videos that are on a Highlight.
So I created an class which implements the IContent interface and changed the PublishedContent of the contentRequest object. This will render the Highlight as is, and not the template of the VideoPage.
Can you change the template programmatically? I tried contentRequest.SetTemplate, but the page went blank with the following parameters:
Am I’m doing something wrong or is this not possible in the current Umbraco?
Berend
Not sure I understand. What you describe seems possible but... when you do new Template(...) you do not retrieve an existing template, you just create an empty template that does not correspond to anything, hence the blank page. I guess what you really want is get the template that should already exist:
var template = ApplicationContext.Current.Services.FileService.GetTemplate("VideoPage");
Hello,
Could you try this:
Jeroen
If you already know the alias of the template this is the easiest:
Jeroen
Thanks Stephan, it worked! I thought it worked like the old api, new Node(NodeId).
If you don't set the template programmatically and you go to the url that the content finder handles you can also set the template by adding ?alttemplate=alias in the querystring. Even content finders support alt templates :-).
Jeroen
is working on a reply...