What is the difference between addbinary () and publishbinary () in XSLT CT?

I was able to publish the binaries in the XSLT component template (CT), referencing the TcmScriptAssistant namespace (xmlns: tcmse = "http://www.tridion.com/ContentManager/5.1/TcmScriptAssistant") and using the following:

<h2>PublishBinary()</h2> <xsl:element name="a"> <xsl:attribute name="href"> <xsl:value-of select="tcmse:PublishBinary(string(./@xlink:href))" /> </xsl:attribute> <xsl:value-of select="./@xlink:title" /> </xsl:element> 

I recently tried AddBinary:

 <h2>AddBinary() with webdav</h2> <xsl:element name="a"> <xsl:attribute name="href"> <xsl:value-of select="tcmse:AddBinary(string(./@xlink:href), '/webdav/040 CreateandBreak/Root/Media/Image', 'some_variant')" /> </xsl:attribute> <xsl:value-of select="./@xlink:title" /> </xsl:element> 

The resulting markup for both:

 <h2>PublishBinary()</h2> <a href="/Media/buddy_tcm7-274.jpg">buddy</a> <h2>AddBinary() with webdav</h2> <a href="/Media/Image/buddy.jpg">buddy</a> 

I see that addBinary used a different folder (group of structures) as indicated in the second parameter.

Did I incorrectly enter the third parameter for the String variantID parameter? I am not sure if I should see its text in the name .jpg.

Any other differences between PublishBinary and AddBinary, especially when using XSLT CT?

I am trying to figure out whether to use each other.

For clarification, I believe this is an AddDinary Object Model of a Tridion object under the TCMScriptAssistant class (and not TOM.NET). I'm sure XSLT CT will remain supported, but I will follow another question about the best ways to handle binary files, possibly in modular templates.

Additional Information: - Trimion 2011 SP1 Schema has links to multimedia components embedded in XSLT CT pages to create โ€œstaticโ€ component presentations

+4
source share
1 answer

AddBinary () is the preferred method. It was introduced with R5.3, I think. This gave us the opportunity to make several versions (variants) of binary files and put them in certain SG. The reason you do not see the variant identifier in the file name is because it is used as metadata in the Broker to retrieve (or link to) certain variants of multimedia components. If you look at the TOM.NET API, you will see additional parameters for things like the option prefix (which will become part of the file name).

You may have problems if you use both methods in your code. I highly recommend that you think of PublishBinary () as โ€œbackward compatible onlyโ€ and use the newer method.

Happy coding

Chris

+4
source

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


All Articles