1

Please let me know How to call Vbscript function in the Compound template (using C#fragment) in Tridion 2011?

TridionDev
  • 11
  • 1
  • 3
    Hi TridionDev. Thanks for your question. In case you didn't know, there is now a dedicated Tridion Stack Exchange site at http://tridion.stackexchange.com – David Forster Apr 03 '13 at 14:02

3 Answers3

4

I'm pretty sure this isn't possible. You can't mix the legacy templates with Modular templates.

johnwinter
  • 3,624
  • 15
  • 24
  • 1
    Slight correction: you can not mix legacy Template Building Blocks with modular Template Building Blocks. You can however perfectly well use a VBScript Component Template for a Component Presentation on a Page that uses a modular Page Template. – Frank van Puffelen Apr 04 '13 at 01:10
3

Sounds like you are mixing legacy style VBScript page templates with current style Compound component templates (or something similar). Mixing the two types is (sometimes) possible, but you cannot call functions in page templates from your component templates like you could with a pure VBScript setup.

You will need to re-implement your VBScript function's functionality as either a Dreamweaver template callable custom function or a .Net based Template Building Block (C# fragment or .Net assembly) depending on your use case.

Community
  • 1
  • 1
David Forster
  • 1,390
  • 9
  • 16
  • Thanks for your suggestion david. But for my case existing Component template is using Vbscript TBB so i want use the same VBScript TBB to other Component template caratedy by Compond template. So could you please advice how to call the existing Vbscript TBB using C#Fragments. – TridionDev Apr 03 '13 at 14:32
  • You cannot call a function in a VBScript TBB from a C# fragment - The two templating frameworks are simply not compatible in that way. You must re-create the functionality using something which is compatible with compound templating. – David Forster Apr 03 '13 at 14:54
  • 1
    You can use a Component Template in VB with a Page Template in C#/Modular Templates. But you cannot use VB and C# in the same template – Nuno Linhares Apr 03 '13 at 15:16
2

OK - just for fun, a strictly literal answer. Please note that I do not advocate this approach.

  1. Write your function in VBScript
  2. Convert your VbScript file into a Windows Script Component
  3. Create a .NET Interop wrapper for your Windows Script component
  4. Put the thing in the GAC I should think...
  5. Call it from your C# fragment

As I said - this is a strictly literal answer to your question as stated. It's enough to say that it's technically possible to do what you are asking, but it won't be useful, because apart from all the technical grief of working through all those layers, what you want to do in a template is usually to invoke the Tridion APIs, and of course, the APIs that are available from the VBScript templating environment are different from the ones available via Compound Templating.

In practice, you'll probably find that your old VBScript templates are due for a re-write anyway. Having to do this occasionally is a good thing.

Dominic Cronin
  • 6,062
  • 2
  • 23
  • 56