RenderComponentPresentation before any other Tridion Razor Page layout

I have a page template in Tridion 2011 with Razor code that prints information based on RenderComponentPresentation () as the first thing on the page. There is no other markup in front of it, because the component, not the page, contains the initial markup. If I did not put at least one character before the first RenderComponentPresentation in the published release, the template refuses to display any presentations.

So, for example, if that's all that is in the TBB layout, this works (in my real code, tcms are real, of course):

<
@RenderComponentPresentation("tcm:mytcm","tcm:myothertcm")

But it is not

@RenderComponentPresentation("tcm:mytcm","tcm:myothertcm")

The first prints the contents of the component preceded by "<", while the second does nothing. I do not want to have ANY markup directly at the beginning of the page template, I want the component to be the first. Is it possible?

+5
source share
3 answers

I just did a quick test in Template Builder using the latest version of Razor Mediator (1.2) and could not replicate your problem.

Perhaps you could try:

<text></text>
@RenderComponentPresentation("tcm:mytcm","tcm"myothertcm")

It will not do any additional markup, but it can trick the intermediary into what you want (although, as I said, I can not replicate your problem, so I can’t check if this does not).

+3
source

, Razor ,

@foreach(var cp in ComponentPresentations){
   @cp.RenderComponentPresentation()
}

. . ( , , , , Razor TBB). .aspx, HTML ? ? HTML - ?

, , :

@RenderComponentPresentation("tcm:x-xxx-xx", "tcm:xx-xxx-xx")

, HTML, .

+2

A bit of a hack, but you tried:

<text>@RenderComponentPresentation("tcm:x-xxx-xx", "tcm:xx-xxx-xx")</text>

or

@Html.Raw(RenderComponentPresentation("tcm:x-xxx-xx", "tcm:xx-xxx-xx"))

Disclaimer: Razor reseller is not actually used. Just a razor.

+1
source

All Articles