15

Ensure that item.EmbeddedSchemaName.EmbeddedSchemaFieldName is non-null for each item: @foreach(dynamic item in List) { if (item.EmbeddedSchemaName.EmbeddedSchemaFieldName != null) { @item.EmbeddedSchemaName.EmbeddedSchemaFieldName } } It may be worth doing the same check for item.EmbeddedSchemaName. From the Razor Mediator ...


14

Well, problem solved. When adding the XML tags to the Tridion.ContentManager.config file, I missed an important node. Inside <configSections> is another registration for the Razor Mediator .dll which points out its configuration details. I had neglected to include this in my manual implementation of the Mediator... How embarrassing! Correcting this ...


14

In a Component Template TBB, you don't have (direct) access to the Page object. The property ContextItem would return the Component that is being rendered with the current Component Tempalte. Please check that, as I'm not familiar with what TridionHelper should do. Hence your code ContextItem as Page will return null. Back to your question -- how to pass ...


13

There's currently not a built in helper method with the Razor Mediator that does this, but there's still different things you can do. First you'll have to understand that Tridion doesn't just "resolve" paths on its own. Behind the scenes with Razor and DW Mediators, tags marked like <img src="tcm:x-xxx" /> automatically have the binary pushed to the ...


12

You can use your Custom Dreamweaver Functions from a Razor Mediator Template with some configuration changes. Your DW functions are in a DLL that is stored in the GAC, and you can reference and use that dll from Razor Mediator. To be able to call those functions you'll have to do the following. First, you'll have to edit the Tridion.ContentManager.config ...


12

Some tags are written out automatically, for example if you use the RenderComponentPresentation() method it will output the markup for a component presentation, and if you use RenderComponentField() it will output the markup for a field. New in 2013 SP1 are the FieldStartMarker(), FieldValueStartMarker(), FieldEndMarker() and FieldValueEndMarker() ...


11

Since the @ signifies that you are breaking out of text mode you need to use a text tag to add the line breaks in for plain text. @if(Fields.Title != null) { <text>@Fields.Title</text> } @if(Fields.Subtitle != null) { <text>@Fields.Subtitle</text> } Outputs: Title Subtitle


10

You can check the version installed by looking at the configSections element in the Tridion.ContentManager.config file, at the section for the razor.mediator. <section name="razor.mediator" type="Tridion.Extensions.Mediators.Razor.Configuration.RazorMediatorConfigurationSection, Tridion.Extensions.Mediators.Razor, Version=1.2.0.0, Culture=neutral, ...


9

I had the same issue, I ended by having my custom razor functions in a cshtml file in my .Net Project. <razor.mediator cacheTime="60" extractBinaries="true" adminUser="Administrator"> .. <imports> <add import="[MyProjectPath]\Functions.cshtml" /> <imports> .. </razor.mediator> I hope this helps.


9

I developed Visual Studio 2010 Extension (might be working in 2012) for synchronization Visual Studio *.cshtml files with Tridion TBBs via CoreService http://code.google.com/p/visual-studio-extension-4-tridion-razor-mediator/ The main idea how to make razor mediator files editable is next: Add next web.config to 'fake' ASP.NET MVC application <?xml ...


9

You won't be able to get the embedded schema directly with the Razor Mediator, but since its just a wrapper of the TOM.NET API, you can create your own function that returns the schema's title. The following example allows you to pass it a ComponentModel instance and a name of the field that you want to get the embedded schema's title for: @using Tridion....


9

According to this helpful post by Dominic Cronin You can use "text" tags in order to do this. So the final if statement looks like this: @if (Fields.releaseMediaTitle == null) { <text> <div class="col-sm-12"> <a href="http://www.example.org"> </text> } else { <text> <div class="col-sm-8"> &...


8

What you're trying to achieve is not as trivial as you think. Component Linking is a Content Delivery feature and it takes into account a lot of variables, such as "is this component published", "which component template has the highest priority" and if the component is published in multiple pages with the same template priority, "which target page is ...


8

This is due to the (optional) management of dependencies that is a feature of the Razor Mediator. If (in Tridion.ContentManager.config) you set the includeConfigWhereUsed attribute to true in the Razor configuration section then every Razor TBB you subsequently create or edit will have a dependency on Razor TBB(s) set to globally import in the imports ...


8

Your solution seems fine, except for the hardcoding of the CT's TCM ID. So it sounds like you need a way to reference the component template without hardcoding the TCM ID. Have a look at the comments in the answer here: https://stackoverflow.com/a/10802912/1284894 The solutions discussed are to: add a Parameter schema on the DWT TBB that specifies the ...


8

Alex Klock's website CodedWeapon where we had gotten the original instructions on how to load an external dll for use in Razor shows 2 ways to reference the assembly. The solution to our problem lies in the second method, namely referencing the dll from the GAC: <razor.mediator extractBinaries="true" adminUser="NT AUTHORITY\SYSTEM"> <namespaces&...


8

You have three options to retrieve any values from the package, which would include parameter schemas: @Package.ItemName @Package.GetByName("ItemName").GetAsString() @Package.GetValue("ItemName")


8

Have you referenced the assembly (in the GAC) within your Tridion.ContentManager.config file? For example: <razor.mediator cacheTime="60" extractBinaries="true" adminUser="DOMAIN\AdminUser"> <namespaces> <!-- ... --> </namespaces> <assemblies> <add assembly="RazorSample.Test, Version=1.0.0.0, Culture=...


8

There are two parts to this answer. The first was pointed out by Jonathan Williams, I was missing the assembly reference in the razor.mediator configuration <razor.mediator cacheTime="60" extractBinaries="true" adminUser="DOMAIN\AdminUser"> <namespaces> <!-- ... --> </namespaces> <assemblies> <add ...


8

It turns out that I was on the correct path, but had missed adding the proper using statement to my TBB. By inserting @using System.Globalization; at the top of my TBB I was able to use either of the methods that I tried originally without issue.


7

In Razor you can use a <text> element to explicitly identify content, so try something like: <text> { "timeline": { </text> @* MAIN SCHEMA FIELDS *@ @Fields.headline <br /> @Fields.type <br /> @Fields.text <br /> @Fields.startdate.ToString("dd/mm/yy) <br /> <...


7

I found the answer: Component.TridionObject.RevisionDate


7

Here are the RAZOR functions that we wrote to accomplish this: (hope this helps someone) @functions{ @* ========================================================================================== <summary>Get the TCM number based on the WebDAV path sent in.</summary> <param name="webdav">WebDAV path of the object to find TCM of&...


6

Try using the <text> wrapper around your statements, in order to help the parser identify them properly. See https://stackoverflow.com/questions/5369540/razor-renderpartial-exception-expected


6

Have you tried: @Package.GetValue("Component.Metadata.ref")


6

You could use: <text>stars:</text>@Metadata.stars Read more here: http://weblogs.asp.net/scottgu/archive/2010/12/15/asp-net-mvc-3-razor-s-and-lt-text-gt-syntax.aspx


6

The Razor Mediator has excellent documentation, including the info you're looking for: https://code.google.com/p/razor-mediator-4-tridion/downloads/detail?name=RazorMediatorDocumentation_v1.3.3.docx In your case I think you'll want to use the @Publication.PublicationUrl to get the URL then concatenate the @Page.FileName onto the end of it.


5

Bart's answer works but it's a strange issue. I don't want the <text></text> tag in my HTML. It seems that applying Bart's solution to the foreach loop my problem is solved and won't show the <text></text> tag in the HTML. Adding the tag to other parts it will show the tag in my HTML. So here is what does what I want: CODE { "...


5

I'm assuming based on your code and comments that you are attempting to do something along the lines of: (I modified the code a little to what the LINQ statement should look like, assuming that Fields.Articles is a list of Component Links, and each of those Components contains a field with Xml Name of "Date"). @using System.Linq; @using Tridion.Extensions....


5

There are pros and cons to every Template language you will choose, while on of the biggest pros for Razor Templating will be that you have the power of .NET available inside your Razor Templates, this also means you leave functionality like you have in DWT Templates behind. So your DWT Custom functions are useless and will have to be replaced with Razor ...


Only top voted, non community-wiki answers of a minimum length are eligible