Hot answers tagged

12

Jamie has included some great suggestions. All of which I recommend over this one, but most people don't realize that there is limited string manipiulation possible using JScript functions (i.e. substring and indexOf) within DWT TBBs. So this is possible: @@"chris@blah.net".substring(0,("chris@blah.net").indexOf("@"))@@<br/> @@"chris@blah.net"....


10

Please try @@Page.ID@@ Code Master.PageID = "@@Page.ID@@"; Master.PageID = "@@Page.Id@@"; Master.PageID = "@@Page.id@@"; Output Master.PageID = "tcm:35-32789-64"; Master.PageID = ""; Master.PageID = "";


9

Siva answered how you check for inequality, but I'll chime in how to check for existence. The equivalent of String.IsNullOrEmpty(Component.Key) would probably be <!-- TemplateBeginIf cond="Component.Key" --> This condition will only pass if Component.Key exists and it has a value. People often use that construct to ensure that a field exists/has a ...


9

Depending on what the use case is, there are several approaches, for example, do you want to apply this behaviour to all the email addresses in the output? is it in a specific situation? If it is the first case (apply to all email addresses) you can achieve that by implementing a C# TBB that "finds" all the email addresses (with a regular expression for ...


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

It's only a checkbox when displayed in the CME. Basically it's a field like any other, so you can just check for the actual value. Something like this should work: <!-- TemplateBeginIf cond="MyField='MyValue'" --> ... <!-- TemplateEndIf -->


8

This is absolutely possible and in your case it is not working because the syntax that you have used is incorrect: You should have written your code as <!-- TemplateBeginIf cond="'title'=='title'" --> Instead of <!-- TemplateBeginIf cond="'title' == 'title'" --> Mind the space before and after the equal operator. Also, consider the ...


7

I think the best way to do it is to add a C# Fragment or .NET TBB to calculate the number of elements you will be rendering in your DWT and push it in a Package Variable so that you can access it. <div class="orbit-slide-number"> <span>1</span> of <span> @@NumberOfElements@@ </span> </div>


7

The code inside the <!-- TemplateBeginRepeat --> has context... Just test your value as such. Also, you need an "is equal to" operator, rather than an "equals" I think ;) The following works for me... <!-- TemplateBeginRepeat name="OffersText" --> <!-- TemplateBeginIf cond="Select == 'Offer A'" --> <div class="col-sm-3 ...


7

Try this way <!-- TemplateBeginIf cond="Component.Key != 'TrackingTag'" -->


6

This is not possible via DWT. The 'name' value of TemplateBeginRepeat cannot be evaluated. You can write another TBB that loops through the package finding your comp1, comp2 and etc and rendering each component. You can also use @@RenderComponentPresentation(compID, templateID)@@ inside your top-level CT and avoid relying on GetLinkedComponents. Finally ...


6

The easiest way is to modify the Tridion Page Template(s) to include something like this in your Dreamweaver Template Building Block: <!-- PageId: @@Page.Id@@ --> At publish time Tridion will resolve Page.Id to the current page's ID and output something along these lines: <!-- PageId: tcm:123-123-64 --> If you're not using Dreamweaver ...


6

<!-- TemplateBeginIf cond="Field.Values(1) != ''" --> ... <!-- TemplateEndIf --> above will check if checked


5

You can also use the Nuno's Get Extension that is available here That approach is very interesting and very useful, you don't need to create a C# TBB, but you will need to register the Get extension in the GAC.


5

@@Component.Description@@ is a shortcut which in 2009 mapped to the only available Description field, which was your text field. In 2013 (possibly already in 2011) they introduced a bit more content in the SDL Tridion Template Expression Language via the Dreamweaver Mediator. One of those were the description fields of a Schema. Hence that now @@Component....


5

Assuming you want to render a component presentation on a PT. To render a component presentation selectively, you need a way to identify it. If you want to do it based on the component title, you can do it like below: <!-- TemplateBeginRepeat name="Components" --> <!-- TemplateBeginIf cond="Component.Title == '[Insert Component Title]'" --&...


4

You can set a Context Variable in a TBB and use it in a Page Template, what you need to do is the following thing. Instantiate the Context Variable (Page Template) engine.PublishingContext.RenderContext.ContextVariables.Add("ContextVariable", string.Empty); Set your context variable in a .NET TBB or C# Fragment (Component Template) TcmUri linkId = new ...


4

I am confused as to why you cannot directly use the field @@episode_number@@ rather than using built-in function in your DWT. If it is in the component it should be accessible. Otherwise I would recommend posting your component xml to give a better idea. And, indeed as @Eric mentions the DWT is evaluated inside to outside, so the innermost repeating region ...


4

Id is a property of the linked component, not a reference to the component itself - You already have that with Fields.list[${TemplateRepeatIndex}] Try removing the Id from your href and alt attributes. <!-- TemplateBeginRepeat name="list" --> <div> <a href="@@Get("Fields.list[${TemplateRepeatIndex}]....


4

Is your main challenge to make the Alt attribute come from the Multimedia component's metadata field or to simply output an images that are added to RTFs? If the latter, then simply output the RTF in DWT @@myRTF@@. Tridion will take care of outputting the image tag correctly, and Editors can specify the Alt text for the image as they insert it, directly in ...


4

I understand Tridion 2009 added the FieldPath variable to help handle multi-value embedded fields. For reference see https://stackoverflow.com/q/10309577/395495 and Frank van Puffelen's explanation on how this worked in the Tridion Cookbook Example. For the new XPM markup, though the methods have changed (and RenderComponentField has been deprecated), you ...


4

Welcome to Stack Exchange Arnaud. This page on SDL Live Content (login required) shows the various options you have for linking. You can achieve the functionality you want with something like this: <input id="blahblah" rel="something" tridion:href="@@Field.theme.form@@" tridion:targetattribute="rel" />


4

Let me use an explicit but hypothetical example to add an answer. It looks like a "Parent" is a News Topic or event of sorts, which can have individual News Stories. For example: /News/Weather/Default.aspx /News/Weather/SanDiegoRain/Default.aspx So the requirement is to know or maybe render something related to "Weather" while on the "San Diego Rain" page? ...


4

If you want to render all components using a given template you can use Will Price's Group Components By Template Type TBB found here: https://sdltridionworld.com/community/2011_extensions/generic-2011-tbbs.aspx This will group all components using the same templates onto an array on your package which you can iterate over using: <!-- ...


4

There is a TBB called Get Linked Components in the Template Base framework for DWT. You can find it here: https://www.sdltridionworld.com/community/2011_extensions/generic-2011-tbbs.aspx. It will add those nested components to your package that you can easily access without funky DWT hacks.


4

DWT is not that powerfull to read fields from linked components out of the box. You can check SDL AppStore to see i there is some templating (dwt) extensions that can read fields from linked components. If you want to read those fields without extension you can write c# code fragment (or .Net assembly) in order to read and push content to the package from ...


4

I guess your template uses the Dreamweaver Get Extension, which is not installed on your system. See https://appstore.sdl.com/web-content-management/app/dreamweaver-get-extension/669/


3

If this is Razor Mediator for Tridion (Alex Klock's extension), then you may want to use TridionObject: @foreach (var c in Package.TridionObject.allItemsInFolder){ @c.RenderComponentPresentation() }


3

DWTs are executed from inside to outside, it means that the repeat section and GetVariable are executed before SetVariable so that your episode number is not set yet. Try to set the variable in the repeat section (i know it would be extra processing), it will ensure the variable is available when you execute GetVariable Other option would be of course to ...


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