11 votes
Accepted

Adding line breaks in plain text when using Razor

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</...
9 votes

How to include partial (unbalanced) html in a Razor Mediator if statement?

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> ...
8 votes

Using Tridion2012UI Experience Manager tags with Razor templates

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" ...
8 votes

Using Tridion2012UI Experience Manager tags with Razor templates

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"> ...
8 votes
Accepted

How do you access the field of a parameter schema from a Razor Mediator Template?

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")
  • 2,512
8 votes
Accepted

Translating months in Razor

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 ...
  • 2,512
6 votes

how get the current page URL in Razor Template and TOM .Net?

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 ...
  • 2,512
5 votes
Accepted

Using Razor Mediator for Outbound Email Templates

I think you're right Harald, for 2013 it appears as though you don't need to call the "Initalize" method but can instead pass TridionHelper.Engine and TridionHelper.Package to the "...
5 votes

unable to get template type with id:8 while publishing

Razor seems to be registered with different id or its not installed at your CMS server, but template expecting it with Id:8 Check your Tridion.ContentManager.config, it should be like below: <...
  • 5,857
5 votes
Accepted

How to include partial (unbalanced) html in a Razor Mediator if statement?

Many ways to do this, but two that haven't been listed: @{ var colorClass= Fields.subtitle != null ? "subtitleColor" : "no-color"; } <div class="@colorClass"> That has the advantage of ...
  • 1,441
5 votes
Accepted

How to consume XML sent by C# TBB in Razor template?

AFAIK, you won't be able to get the Keyword titles directly in a Razor TBB; however, you can create your own custom function in the Razor TBB that manipulates the XML and returns the titles. The ...
5 votes
Accepted

Is Razor Mediator compatible with Tridion Sites

The Razor Mediator is and community built extension and thus is not supported by SDL. However it is using the Modular Templating Framework and its supported extension points, so from that perspective, ...
  • 29.6k
4 votes

How do you access the field of a parameter schema from a Razor Mediator Template?

And for regular fields, you can do something like this: @Fields.className For more info about Razor syntax, have a look at the documentation here: https://code.google.com/p/razor-mediator-4-tridion/...
4 votes

How to get the Session in a Razor template

The Session in Tom.Net is available on most objects as '.Session'. I got a nice hint from Frank Taylor's blog post where he used Component.TridionObject.Session and then I was also able to use ...
  • 10.2k
4 votes

Publisher service not finding Razor Helper methods

Just in case anyone is still having this problem, I solved it by adding the NT AUTHORITY\SYSTEM account (the account that the Publisher Service runs under by default) as an impersonation user. This ...
4 votes

Why do we need to add NT AUTHORITY\SYSTEM to impersonation users?

Its probably got something to do with the AdminUser which can be configured in the Razor Mediator configuration. From the docs: AdminUser Attribute The "adminUser" attribute allows you to specify a ...
  • 16.4k
4 votes
Accepted

Access the field path of an item inside of a foreach loop using razor templating?

I accessed an item using a for loop, and having an index. There might be a better solution though. @for (int i = 0; i < Fields.MultivaluedField.Count; i++) { @RenderComponentField("Fields....
4 votes

DD4T with Razor Templating - feasibility

A few rough answers on your questions: Simply considering DD4T is slower then Razor Templating is not a valid statement if you ask me. There will be a lot of questions you need to asnwer before you ...
  • 29.6k
4 votes
Accepted

Razor Mediator for Web 8

Yes, it is supported in Web 8. You can download the latest version here, http://razor-mediator-4-tridion.googlecode.com/files/RazorMediatorInstaller_v1.3.3.1.msi There is also a nice presentation ...
  • 10.2k
3 votes

Razor Mediator Template Timeout on Save

Looking at the error, it feels like that database is timing out. That is the case when you will see error "The transaction associated with the current connection has completed but has not been ...
  • 3,728
3 votes

Editing Razor TBBs in Visual Studio

Here is in my blog explained how to debug Razor Mediator .cshtml files in Visual Studio. http://mvlasenko.blogspot.com/2015/12/debugging-razor-mediator-templates.html
3 votes

Publish binaries in a package - more info

It seems that you are using Razor Mediator for your templates. Razor Mediator have the capability to automatically add Binaries to to the Package <razor.mediator extractBinaries="true" adminUser="...
  • 9,352
3 votes
Accepted

Loop thrugh StructureGroups with Razor MEdiator

you can try below code, I havn't run this though. OrganizationalItemItemsFilter filter = new OrganizationalItemItemsFilter(TridionHelper.Engine.GetSession()); filter.Recursive = true; ...
3 votes

How to include partial (unbalanced) html in a Razor Mediator if statement?

Adding to the @Damian's answer, if you don't want to write the mark up multiple times, one option could be to place the it(html generation logic) inside a function like below: @functions { public ...
3 votes

How to include partial (unbalanced) html in a Razor Mediator if statement?

I'm assuming you are just trying to avoid writing out the markup after the first tag twice? If so, another possible solution would be to use multiple Razor Mediator Templates and "chain" them ...
3 votes

Embedded Razor Templates

When a template is compiled by the razor mediator, any embedded templates are resolved and the text is embedded before compilation occurs. The resulting assembly is cached, and that's the last time ...
3 votes

Checking non-nullable fields for values in Razor Mediator

Since you know that the default value for a datetime in Tridion is the minimum value of the datetime object, you can do a comparison like: if(!Metadata.Date.Equals(DateTime.MinValue)){ code } The ...
  • 2,512
3 votes

How to consume XML sent by C# TBB in Razor template?

Adding to @Sabarish's answer, If you are interested in Titles only; get the lighter XML for Keyword list which only contains ID and Title. To do so you should apply the filter in your TOM.NET C# Code ...
3 votes

How to consume XML sent by C# TBB in Razor template?

Piggy-backing on the answers of Saurabh and Sabarish, I would suggest doing something similar, but moving the XML processing code Sabarish suggests (with Saurabh's modification) out of the Razor ...
  • 2,512
3 votes

XPM in SDL web 8.5 with Razor Mediator

AFAIK - Question1: my question is whether the same IsSiteEditEnabled Razor mediator built-in function will work for SDL web 8.5 Answers: Yes. if you are using the legacy publishing target and ...
  • 7,545

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