How can I use flash files in my SDL Tridion page? - tridion

My page is showing regular component presentations very well.
I have a flash/video file in my local machine and i want to upload this file on my page.
How can I achieve this?
I have this code snippet for rendering components on my page:
<!-- TemplateBeginRepeat name="Components" -->
<!-- TemplateBeginIf cond="ComponentTemplate == 'HomePageCT'" -->
##RenderComponentPresentation()##
<!-- TemplateEndIf -->
<!-- TemplateEndRepeat -->
Please provide all details related to flash files and video files.

Placing a Flash file on a page follows exactly the same process as placing any image in the output of your templates. The steps are outlined below:
Create a Multimedia Schema which allows the Flash multimedia type (e.g. Flash Video Schema)
Upload your Flash file using your new Schema
Create a Component Template to render the HTML you want to use to display the Flash file, and actually publish the binary itself. (e.g. Display Flash CT)
Create a page template (you seem to have done this part) which renders the Page, and renders the Components on the page using ##RenderComponentPresentation()##
Create a Page, and place your Flash file on it using the Display Flash CT
Publish the Page
Without details of the output you want to produce, it is hard to provide the sample Dreamweaver Template Building Block code for the DisplayFlash CT, but it might look something like this:
<embed src="##Component.Id##" allowFullScreen="true" width="540"
height="438" bgcolor="#000000" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed>
Make sure you use the Default Finish Actions TBB after this in your Component Template so that the src link is processed and the binary is published.

There is nothing special about Flash files with Tridion. They can be treated just like any other Multimedia Component. You can upload them into the CME (or by using Webdav) and thus you will have a Multimedia Component. Make sure of course, that you Multimedia Schema allows the Flash (and extension) as Multimedia Type.
Regarding how you put the Flash file on the Page - again just like a normal Multimedia Component. In your CT you have to generate the output that will make use of your Flash file URL somewhere. You will have to publish your Flash MMC in order to get its URL. You can use Engine.AddBinary or RenderedItem.AddBinary methods for that, or use the Publish Binaries in Package Default TBB, if your MMC is in the package. Then you can simply refer to your Flash URL as package item. Have a look at this URLs for some inspiration: http://yatb.mitza.net/2012/03/publishing-images-as-variants.html (your case doesn't have to be that complex) and http://yatb.mitza.net/2012/04/referencing-image-variants-from.html.

There are several approaches to rendering Multimedia with a Tridion-managed page.
Multimedia components can be:
Part of a component presentation, added to a page with a template selected
As a linked-to multimedia component within a "container" component, which is added to a page
In a rich text format (RTF) area within another component
You could also just publish binaries with dynamic component templates and handle the markup and links outside of Tridion. Get creative with the above basic scenarios depending on the markup and/or metadata you need.
Chris addresses #1 and Mihai explains schema setup and .AddBinary. The second option would be similar, except you'd have to get the referenced ID rather than the component on the page. The third option requires you to parse multimedia within RTF which depends on your templating language and multimedia type.
I've seen XSLT (<xsl:template match="">), grep, and various .replace options to parse specific markup such as Flash videos.

Related

How can we save multimedia components using external resource types if the URL doesn’t end in with a file extension?

We have a Tridion use case related to curated content where we are creating multimedia components for images associated with our content which are pointing to External resource types instead of uploaded resource types.
One of the issues we have run into with this use case is that despite explicitly setting the Multimedia Type for the resource, if the URL of the image has either a query string in it: http://cdn.hw.net/UploadService/1c8b7f28-bb12-4e02-b888-388fdff5836e.jpg?w=160&h=120&mode=crop&404=default or uses a ‘friendly url’: http://www.somewhere.com/images/myimage/ when we save the component, Tridion barfs with error messages similar to : ‘Invalid value for property 'Filename'. Unexpected file extension: jpg?w=160&h=120&mode=crop&404=default. Expecting: jpg,jpeg,jpe.’
So far, the only way we’ve been able to figure out to potentially get around this issue is to do something hacky like appending an extra query string parameter to the very end of the urls which end with the expected file extension: http://cdn.hw.net/UploadService/1c8b7f28-bb12-4e02-b888-388fdff5836e.jpg?w=160&h=120&mode=crop&404=default&ext=.jpg Obviously, this is not the best solution and in fact may not work for some images if the site they are being served from strictly validates the requested URL.
Does anyone have any ideas on how we can work around this issue?
Unfortunately I can't really think of an easy solution to this, since Tridion "detects" the Mime type by checking the file extension.
You could perhaps add it while saving and remove it when reading (via Event System)? Definitely a worthwhile enhancement request, to my knowledge this behavior has not been changed for the soon-coming Tridion 2013... See comment below, it has been changed for 2013.
+1 for Nuno's answer. Recognizing that the title of your question is specific to multimedia components, you may want to consider another approach which is to use normal Components, not Multimedia Components. You can create a normal component schema called something like "External Image" that has an External Url field to store your extentionless url.
Content authors will then include these images via regular component linking mechanisms in the Tridion GUI.
You will then need a custom link resolver TBB that will parse the Output item (via Regex) looking for any Tridion anchor tags <a tridion:href="tcm:x-y-z"> and for each one replace them with an <img src=...> tag where the src path would come from this linked component.
For an example of a similar approach, but with videos, and sample code for a custom link resolver TBB have a look at the code in the following post: http://www.tridiondeveloper.com/integration-sdl-tridion-jw-media-player.

Need help to create component template using Template building block

I need help with following scenario:
I have page template PT1 , which contains 2 TBBs and I have component template CT1, which contains 1 TBB.
I created a page using the Page Template(PT1) and added a component and selected the component template (CT1).
The TBBs pushing some text value to package and all three TBB are part of a single dotnet assembly and implemented in three different class, which is implementing "Itemplate" interface and implement "transform" method.
Problem:
In the published file i am able to see the content pushing by TBB used in Page Template PT1, but not able to see content which is pushing by TBB of Component Template CT1.
Typically, to output from a template you need to create a DWT TBB unless you are directly sending Output from C# TBB.
In your case, looks like you have all C# TBBs and are they outputting anything to the package. If not then I even doubt your PT will output any html.
You could use the Template Builder tool to debug your out of the template as in my comments the doc portal link will provide you guidance.

Ways to access the Component Presentation other than RenderComponentPresentaion in SDL Trdion 2011 Sp1

In Dreamweaver Templating we can access the fields of a component in two ways.
1.##Component.Field.FieldName##
2.##RenderComponentField("FieldName",0)##
similarly to access the Component Presentation
1.RenderComponentPresentation()
Is there way to access it in another way.
You should really consider editing your question and clarifying it a
bit to make it more clear of what you are asking. Reading all the
answers you dismiss and their comments, I think what you are trying to
accomplish is to have some Component Presentations on the Page editable
and others not.
Depending on the version of SiteEdit you are using there are two solutions:
SiteEdit 2009 SP3 - You should remove the inline editing TBB from the Component Template which you do not want editable, the Page will still generate a hover-over the Component Presentation so it can be moved.
UI 2012 (the new UI or Experience Manager) - You can disable inline editing per Component Template, through the checkbox in the Component Template.
If you also need to have the hover-over on the Component Presentations removed, then I think the only solution is to remove the Inline Editing features of the Page Template (for SE 2009 SP3, remove the TBB and for UI 2012 disable it on the Page Template) and generate all the required SiteEdit marking yourself in the Page Template.
An interesting question to all this would be "why?", what is your requirement exactly to have the need for only enabling inline editing on some of the content on the Page. Since you could also accomplish that through (editing) permissions for certain user groups.
The default TBBs that ship with Tridion, SiteEdit 2009 and the new UI/Experience Manager all insist on generating markup around Component Presentations and Component Fields. You can control the markup elements they generate, but there is currently no way to turn them off.
To gain such full control, I created a simple extension function for use in DWT templates. You can find it here: http://code.google.com/p/tridion-practice/wiki/TridionUI2012FunctionsForUseInHtmlTemplates
RenderComponentPresentation would be from the Page Template, and the first examples are from the Component Template, or within e.g. a repeating region:
<!-- TemplateBeginRepeat name="Components" -->
Fields.*FieldName*
<!-- TemplateEndRepeat -->
But either way, why are you asking?
You can also call RenderComponentPresentation from within another Component Template, using this code:
##RenderComponentPresentation(Component.ID, ComponentTemplate.ID)##
Where the arguments are the tcm ids of the component you wish to render, and the template to render it with.
For dynamic component presentations you can use the following in a page template:
<tcdl:ComponentPresentation type="Dynamic" componentURI="${ComponentID}" templateURI="${DynamicComponentTemplateID}" />
But in this case these dynamic component presentations won't be published during the publishing page. So, you should publish them before publishing page.

Can we edit XML documents in Tridion using SiteEdit 2009?

We have started exploring SiteEdit. We could enable and use it for html pages but can anybody guide us whether we can use it if content is published as XML Document. We have tried doing this but the SiteEdit button is not appearing on the published XML page when accessed through the SiteEdit proxy (on port 84).
SiteEdit allows you to edit your content in the HTML of your web site. So if you render the content into (valid) HTML and add the correct SiteEdit commands to that HTML, you can edit it.
SiteEdit will not enable editing of raw XML you publish. Normally I'd expect to find that same content as HTML somewhere else on the web site and enable SiteEdit there.
If you really think there is value in editing the content in an XML-like view, I suggest finding an XSLT that converts the XML to an HTML view (like Internet Explorer shows it) and add that as a Dynamic Component Template to Tridion. If you then embed the necessary SiteEdit commands into that HTML, you can edit the result in SiteEdit. It will of course have become HTML, but it will still look like you are editing the original XML.

Relative path handling in SDL Tridion

In SDL Tridion, Dreamweaver template, I have to set a relative path to my image in Page Template.
Tridion produces output as below when I do have code like this in DWT.
DWT Markup
<img src="##Field##"/>
Template Renders
<img src="image.jpg"/>
However when I add a relative path like this, the template returns tcmid
DWT Markup
<img src="Folder/img/##Field##" type="text/css" rel="stylesheet"/
Template Renders
<img src="tcm:8-674"/>
And this causes images not being presented properly in website. I tried with Tridion type: multimedia etc, but nothing has worked so far.
Has anyone seen a similar issue before?
The behaviour you experience is that Tridion (the Dreamweaver mediator) will interpret your src image attribute as WebDAV path of an item in the Content Manager. So if it finds a Multimedia Component under Folder/img/##Field##, it will replace your path with the TCMURI of that Multimedia Component. That's expected behaviour.
However, I don't think that's what you are trying to do (it's not clear from your question). Is your image in Tridion as a Multimedia Component? Are you trying to show this image? Then you should use Multimedia Links (i.e. links to a Multimedia Component) in your DWT: <img src="##Compoennt.Fields.link_to_mmc##"/>, where field link_to_mmc is a Multimedia Link field defined in your Schema. Use then also the 'Resolve Links' Default TBB to convert the TCMURI into a relative image path.
If you are linking to an external image, then you need to specify the URL of that image in your DWT template. Something like this <img src="##Component.Fields.external_url##"/>, where external_url is a Text field in your Schema and it contains the actual URL of the external image you want to show.
It seems like you are almost there, only when you add the string as a relative path, the default TBBs don't recognize the uri held in the SRC attribute anymore. If you are trying to publish the binary to a different location, you will need to bind it to a different Structure Group, alternatively try changing the multimedia URL on your publication. that way the images will be published (and resolved) to you sub directory.
If your imagefields field is a link to a Multimedia Component, then all you need is <img src="##Field##"/>. With that Tridion will (in this order):
replace the ##Field## with the TCM URI of the image (e.g. tcm:6-874) when it executes the DWT
put the image item into the package as an implicit step after executing the DWT
publish the images (as one of the steps in the Default Finish Actions)
replace the TCM URI (tcm:6-874) with the path of the published image
Since you'll probably have custom TBBs between the DWT and the Default Finish Actions, you could use those to modify the image item and influence what gets published (and where, using item properties).
If you've set up your Tridion installation correctly, you'll typically store the base path to the images in the Publication properties and then step 3 just puts the the image in there and step 4 puts the full path (including what you specified in the Publication properties) into the HTML.
If you want more control over the relative path, the Publish Binaries in Package and Default Finish Actions TBBs have a parameter that allows you to specify to which Structure Group the images will be published. That way you can have different templates output their images to different Structure Groups/directories on disk.
For the ultimate in control you can also decide to publish the binaries yourself. In that case have a look at the source of the Publish Binaries in Package TBB (available from the forum on SDL Tridion World), modify it to suit your needs and replace the one in Default Finish Actions with your modified version.

Resources