The iframe tag in the component gives an incomplete page when publishing

In Tridion, I have a page attached to a component that has a text box that has an iframe tag, for example <iframe src="http://mysite.com/l/5042/2012-06-21/9pb4y" width="100%" height="500" frameborder="0" style="border: 0" > </iframe> . I guarantee that this tag remains the same as when processing C# & DWT template building blocks . But at the end of the publication of the page, in the source of the page, the tag changes to <iframe src="http://mysite.com/l/5042/2012-06-21/9pb4y" width="100%" height="500" frameborder="0" style="border: 0" /> . Because of this, the page source does not display content after the iframe tag. Thus, any component attached to the page after the component containing the iframe tag is not displayed on the page. Any idea why the closing tag </iframe> is replaced by the closing tag /> ?

+6
source share
3 answers

As Frank pointed out, you can use Convert XML for HTML TBB

 (OR) 

You can also consider the solution from Chris provided in this thread. Create anchor links in text fields with the advanced SDL Tridion 2011 SP1 interface

You use xslt to define the schema field. Although the TBB option applies to full CT / PT depending on where you use it, with XSLT you can use it at the field level and also get the same format when using CoreService for any other use cases.

+6
source

I asked about this, and Jamie Santos helped me with this decision.

I already used Convert XML to HTML TBB , but this did not work because the closing tag was already placed in the output variable.

So, in the next TBB, the Schema [Tags] parameter is used, where we pass the list of tags (Comma Separated) that we want to change the closing tag itself (for example, / ">) with a closing tag (for example)

 [TcmTemplateTitle("Remove Selft Closing Tag")] public class RemoveSelfClosingTag : ITemplate { public override void Transform(Engine engine, Package package) { var outputItem = package.GetByName(Package.OutputName); 
  //if not Output in package, return if (outputItem == null) return; var output = outputItem.GetAsString(); var tagsCsv = package.GetValue("Tags"); //TBB parameter [tags using CSV] : 'iframe' if (string.IsNullOrEmpty(tagsCsv)) return; var tags = tagsCsv.Split(','); foreach (var tag in tags) { RemoveSelftTag(tag, ref output); } outputItem.SetAsString(output); } //ref because string is immutable. private void RemoveSelftTag(string tagName, ref string output) { var pattern = string.Format("(?'fistPart'<(?'tag'{0})[^>]+?)/>", tagName); output = Regex.Replace(output, pattern, @"${fistPart}></${tag}>"); } } 

code>
+1
source

I think this is due to TBB "Clean Up". I would put "empty" space between the tags, something like this:

 <iframe src="YOUR_URL_HERE" width="100%" height="500" frameborder="0" style="border: 0" > &nbsp;</iframe> 

This should not contain markup and display an iframe with a closing tag.

0
source

Source: https://habr.com/ru/post/918822/


All Articles