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:
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 ...
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 ...
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 ...
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 -->
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'" -->
<!-- TemplateBeginIf cond="'title' == 'title'" -->
Mind the space before and after the equal operator.
Also, consider the ...
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.
<span>1</span> of <span> @@NumberOfElements@@ </span>
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 ...
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.
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 ...
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.
@@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....
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]'" --&...
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)
Set your context variable in a .NET TBB or C# Fragment (Component Template)
TcmUri linkId = new ...
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 ...
Id is a property of the linked component, not a reference to the component itself - You already have that with
Try removing the Id from your href and alt attributes.
<!-- TemplateBeginRepeat name="list" -->
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 ...
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 ...
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" />
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:
So the requirement is to know or maybe render something related to "Weather" while on the "San Diego Rain" page?
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:
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.
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 ...
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 ...