I've a problem here. The structure that I have at the moment is:
ComponentA
FieldA1 - textField
CombonentsB - componentLink (multi-value)
FieldB1 - textField
ComponentC - componentLink
FieldC1 - textField
Now I am trying to place ComponentA with Template on a page.
I am using DWT Templating.
What I need is to access FieldC1 in the template.
I've already added the "Add Linked Components To Package" TBB in TemplateA.
I think it is identical to this one:
http://sdltridionworld.com/community/extension_overview/addcompstopackage.aspx
I can access FieldB1 in my template but not the fields further down in the hierarchy.
Do I have to write another TBB that includes the whole hiearchy, or should it work as expected and my access code is just wrong?
<!-- TemplateBeginRepeat name="ComponentsB" -->
##ComponentC.Fields.FieldC1##
<!-- TemplateEndRepeat -->
What can I do to make it work? Are there any other solutions then writing a new TBB?
=========== SOLUTION ============
After Nickoli Roussakov told me about the DGX, I managed to implement it correctly.
Here the code:
<!-- TemplateBeginRepeat name="ComponentsB" -->
##Get("ComponentsB[${TemplateRepeatIndex}].Fields.ComponentC.Fields.FieldC1")##
<!-- TemplateEndRepeat -->
GetLinkedComponents works only on the first level of component nesting because you can't go deeper than that with DWT syntax. Your options are to write a custom tbb that renders out the output needed down from componentB, or try Nuno's DGX extension (also on sdltridionworld) instead of GetLinkedComponents.
Related
As you probably already know, I'm working hard on some XPM templates with Razor. I've ran into another issue, this time concerning rendering components inside templates in order to make them siteEditable.
The following I'm not sure about. I've got a component which has a title field called "Title", and multivalue componentlink fields which consists of components with a title, description and image. Let's call this one "Linked USP" for now.
Currently this is being rendered by a Template called 'Page Banner', and it just iterates over fields with some If-loops to determine it's presentation, especially for the Title. In order for XPM to work, this template needs to render the component presentation of "Linked USP". So we've created a template called "[XPM] USP ITEM". - this Component template has the 'enable content editing TBB" added to it.
Now the issue arises when I want to make the Title Editable as well. Sounds straightforward, no? Not really - because when the parent template has got a "enable for content editing" TBB added, it will add <span> tags to all editable fields but the templates that gets invoked inside this template will also have <span> -tags, effectively bloating the html and making it impossible to edit the fields inside the RenderComponentPresentation because of duplicate <span>s.
Some code for your fun and to illustrate my issue:
<h1>#RenderComponentField("Title", 0)</h1>
#Foreach(var linkedUSP in Fields.USPS){
#RenderComponentPresentation("linkedUSP.ID", "tcm:10-1076-32")
}
This template has an enable Content edit TBB added.
now, for the RCP mentioned above, inside its [XPM] template:
<div class="title">#RenderComponentField("Title", 0)</div>
<p>#RenderComponentField("Description", 0)</p>
<tcdl:ComponentField name="img">
<img src="#img" alt="img.MetaData.alt">
</tcdl:ComponentField>
This one ALSO has the "Enable Content Edit" TBB added. On the front end this happens:
<div class="title"><span><span>Men</span></span></div>
Because the parent template also adds spans to the field.
So my question: how do i solve this? The Title field mentioned above has to be inside the parent template, but I can't create a special template for it becuase it is no component link. I can't get the TBB out of my RCP template, because it won't be editable that way. Interesting huh?
Can't I disable the spans inside template builder somehow?
I'm having a problem enabling multimedia components i.e. image components to be edited through Tridion UI. When I use a General Content Component that has an image field it works fine without any issues as I get the JSON objects below:
<!-- Start Component Presentation: { 'ComponentID' : 'tcm:15-5444', 'ComponentModified' : '2012-12-27T12:07:29', 'ComponentTemplateID' : 'tcm:15-5364-32', 'ComponentTemplateModified' : '2012-12-27T11:30:49' } -->
<div><!-- Start Component Field: {'XPath' : 'tcm:Content/custom:Content/custom:image[1]'} --><img src="/Preview/_images/15-5366Hero%20Banner.jpg" alt="Banner SE"></div>
However When using an Image Schema Component directly with a Component Template the following tags are output:
<!-- Start Component Presentation: { 'ComponentID' : 'tcm:15-5366', 'ComponentModified' : '2012-12-18T13:21:46', 'ComponentTemplateID' : 'tcm:15-5364-32', 'ComponentTemplateModified' : '2012-12-27T11:30:49' } -->
<div><!-- Start Component Field: {'XPath' : 'tcm:Content/custom:Content/custom:Component.ID[1]'} --><img src="/_images/15-5366Hero%20Banner.jpg" alt="Banner SE"></div>
I know that I may not need to use "custom:Component" as this doesn't exist in the XML but can you see what I am doing wrong? Has anybody had any experience using a Multimedia Component directly on a page and been able to have the left hand image selection sidebar display?
Regards,
Billy
The markup you pasted is about inline editing of Component fields.
You can't use it for anything else.
You can inline edit the Metadata fields of an image Component in the Tridion UI, but you cannot upload a new version of the image. For that you will need use Open in Form View.
To get the Library Panel in Experience Manager (XPM), from the Home tab select Insert Content > Insert Content to get access to the left-hand images.
Your images' multimedia schema needs to have an associated Component Template (this is set in the Component Template's Linked Schema). Though you seem okay since you have the image as a Component Presentation already.
At least on my VM, the thumbnails appear automatically.
Is it possible to call the SiteEdit editable content script to output the content from TBB using RenderComponentPresentation method?
Currently, I am getting a red border line wrapped that content. When I roll over the top right corner icon, it is saying removed. However, the component content is not removed, any changes of the component template or page all have been republished and component itself is also not dynamic component.
The SiteEdit is working if I am calling the editable script directly from TBB, but if I am using RenderComponentPresentation method to call another Component Template to output that script. I only get the red border line and saying it has been removed.
Editable script: (working directly from TBB)
<!-- TemplateBeginIf cond="Content != ''" -->
<tcdl:ComponentField name="Content">${Content}</tcdl:ComponentField>
<!-- TemplateEndIf -->
Within TBB calling below method and always getting a red border RenderComponentPresentation(ComponentID, ComponentTemplateID)
Environment: Tridion 2011, SiteEdit 2009 SP3, Windows Server 2008
I guess this is not feasible with RenderComponentPresentation since what you're trying to do is nested component presentations. However you can get this by adding the siteedit markup tags directly with IsQueryBased to true
Please check the link for additional info (bottom of the section): http://sdllivecontent.sdl.com/LiveContent/content/en-US/SiteEdit_2009_SP3/concept_0D0C929C17D74A6292B2AFE0C29F4DCD
Alternative approach is to add the below markup before your nested component presentation (IsQueryBased should be true):
<!-- Start SiteEdit Component Presentation: {
"ID" : "MyCP23", "ComponentID" : "tcm:54-7894",
"ComponentTemplateID" : "tcm:54-3201-32",
"ComponentVersion" : 2,
"IsQueryBased" : true,
"SwapLabel" : "Left"
} -->
If you are rendering a Component which is not on the current Page, then it is to be expected that SiteEdit considers it removed.
You will need to mark the Component Presentation as "query based" so SiteEdit knows not to expect it on the Page. This will disable the functionality which doesn't make sense (such as drag-and-drop to move the CP around on the Page) but will otherwise work the same.
To mark it as query-based, you will need to manually output the markup (see Start SiteEdit Component Presentation command) or use some other tool to do it for you, like the functions created by Frank van Puffelen (note: I believe these only work for the 2011 version). Make sure the IsQueryBased parameter is set to true.
Can anyone direct me on how to use SiteEdit specific syntax or tags in the Razor template in DD4T code? I have seen Site Edit related classes in it, but could not understand how to use SiteEdit tags in the view where there were some syntax similar to Dreamweaver for example RenderComponentField or tcdl:ComponentField which we used in Dreamweaver. I am very new to DD4T and am using SiteEdit 2009 SP3 and SDL Tridon 2011 SP1.
Thanks in advance.
Update: We have tried the implementation mentioned in the answer but unfortunately we are getting an error when we are accessing the page in proxy stating "Invalid template -The HTML is invalid, probably because your template code produces invalid HTML, such as a p tag inside another p tag. Check your HTML using a validator such as the W3C Markup Validation Service, correct your template, and republish."
I guess this is because Xml content is being pushed into html page due to the use of Dynamic Page and Component TBBs which we used in our Component and Page Templates.
Let us kow how to continue further.
The SiteEdit markup is not generated like it is done in a Dreamweaver Template, you are responsible yourself to place the markup for your editable fields in the Razor view. Good thing for this is that it works for similar for SiteEdit 2009 SP3 and UI 2012. Downside for UI 2012 is that it is not listening (yet) to the Enable Inline Editing which you can set on the Component or Page Templates (something we should consider for a future DD4T version).
Everything is based on the DD4T SiteEditHelper class. You start in your page view (before the </body> tag) by placing the following call:
#Html.SiteEditPage(Model)
This will write out the page markup, and if you set the style to "SiteEdit2012" in your SiteEdit_config.xml it will also write out the bootstrap script required for UI 2012.
Then for every Component Presentation and every editable Component Field you will also need to add the appropriate markup. For a Component presentation you can use:
#{var ComponentPresentation = ViewBag.ComponentPresentation as IComponentPresentation;}
<div>
#Html.SiteEditComponentPresentation(ComponentPresentation)
</div>
Make sure you write this out inside a DIV or some other element that can mark the boundary of your Component Presentation. For Component Fields a similar story, you can use:
<div>
#Html.SiteEditField(Model, Model.Fields["FieldName"])
#Model.Fields["FieldName"].Value
</div>
Apart from the changes to your views, as Bart has described, you also need to put a configuration file in the root of your web application, called SiteEdit_config.xml. It should look like this:
<?xml version="1.0" encoding="utf-8" ?>
<siteEdit enabled="true" tridionHostUrl="http://tridion.my.com">
<contextPublications>
<contextPublication id="10" componentPublication="3" pagePublication="9" publishPublication="10" />
<contextPublication id="11" componentPublication="3" pagePublication="9" publishPublication="11" />
</contextPublications>
</siteEdit>
You must list all your active publications here. DD4T tries to match your current page to the correct context publication (based on the 'id' attribute). If it cannot find it, SiteEdit will be disabled. The other attributes allow you to control the behaviour of SiteEdit.
componentPublication: new components will be created here
pagePublication: new pages will be created here (not used in Tridion UI 2012)
publishPublication: pages and components will be republished from this context (usually coincides with the id)
DD4T can also easily be configured for use with Tridion UI 2012. Just change the first element in the configuration as follows:
<?xml version="1.0" encoding="utf-8" ?>
<siteEdit enabled="true" style="SiteEdit2012" tridionHostUrl="http://tridion.my.com">
...
</siteEdit>
I have a schema containing a multi-value field of type component link.
How can I render this field (component link with its template) when I write a DWT TBB for this component?
A Component Link field links to a Component - it does not specify a template. So I'll assume you want to specify the Component Template to use on the DWT.
<!-- TemplateBeginRepeat name="Component.Fields.YourComponentLinkFieldName" -->
#RenderComponentPresentation(Field, "tcm:1-2-32")##
<!-- TemplateEndRepeat -->
So this loops over all values of the multi-value field names YourComponentLinkFieldName and render the Component linked in there with Component Template tcm:1-2-32.
All of these topics are relevant to your question:
Retrieving values of a linked component in Dreamweaver TBB - and making it SiteEditable
How to handle nested repeating regions in Dreamweaver TBBs in SDL Tridion 2011 SP1
Retrieving values of a linked component in Dreamweaver TBB - and making it SiteEditable
I suggest you read them and apply your understanding of them.