Question

Is there a way to use razor variables in PageTemplateFeatures in C1?

I have this in MasterLayout.cshtml:

@inherits CompositeC1WebPage @{

string stylesFolder = "~/Frontend/Styles";
string jsFolder = "~/Frontend/Scripts";
string imgLayoutFolder = "~/Frontend/Images/Layout";
string imgSliderFolder = "~/Frontend/Images/Slider";
string websiteTitle = HomePageNode.Title;

}

And I'd like to reference these variables in the PageTemplateFeatures.

Thanks, Robert

Était-ce utile?

La solution

Probably not.

A Page Template Feature is actually an .html or .xml file. To make the system aware of the Razor syntax in the file, the file should be .cshtml (see also http://www.w3schools.com/aspnet/razor_syntax.asp). If you try and replace the extension of the template feature's physical file, you'll lose the feature to the system.

I have a suggestion: How about moving all the Razor related code to a Razor function and then insert this function in the template feature. The function should of course both declare variables and use them.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top