1

For a client I'm finally migrating a Tridion 2011 environment to Tridion Site 9.1.

It took my already a lot of time to do the upgrade/install of the Content Manager and the Content Delivery but most of this is finally working. (My experience was stuck on Tridion 2013 so a lot of concepts introduced in Web 8 and Site 9.1 are new for me).

Unfortunately I discovered (to late) that the Content Interaction Library (CIL) cannot be used to render ASCX fragments. And we are using this a lot on the different sites hosted by the Tridion environment.

We have some dynamic component templates with output format "ASCX Webcontrol" this are published to filesystem. We load a list of components with one of this templates on a page.

Our initial code looked like


ComponentPresentationAssembler Assembler = new ComponentPresentationAssembler("tcm of puplication", page); //Page is the aspx page System.Web.UI.Page string content = Assembler.GetContent("tcm of component","tcm of component template");


With the CIL this was always returning empty content. So I have done following changes:

  • change the output format to REL
  • modify the constructor for the ComponentPresentationAssembler by using new ComponentPresentationAssembler(publicationID, pageId);
  • for testing I have also stored the ascx to database and then they are loaded like for REL

The result of this was that the content was not empty anymore but the tridion:ComponentLink tags are not executed but rendered in the html instead. That was also the reason why in the original project we were storing the ascx files on filesystem.

So I'm looking now to a solution to be able to load more or less this component pressentations in the same way like we did in the past without to many modifications.

Is it for example an option to still publish the ascx files to filesystem and write our own logic to get this directly from file system? If yes what is the best way?

Or is there some trick that I can use to 'execute' the component presentation when the data is coming from database instead?

Thanks for all the help!

3 Answers 3

1

Yes, in Tridion 9.1 we can still publish items to the file system.

In the cd_storage_conf.xml where the Discovery Service is installed, add the <Storage> element to publish files to the file system inside the <Storages> element like this:

<Storage Class="com.tridion.storage.filesystem.FSDAOFactory" Id="ascx" Type="filesystem" defaultFilesystem="true">
    <Root Path="C:\Temp"/>
</Storage>

To ensure that only ASCX files are published to the file system, inside the <ItemTypes> element, add an <Item> element setting the itemExtension to .ascx and the typeMapping to ComponentPresentation.

<Item cached="false" storageId="ascx" itemExtension=".ascx" typeMapping="ComponentPresentation" />

Restart the Discovery Service. This should deploy the .ascx files on to the path specified in the Storage element.

1
  • Publishing to filesystem is indeed still working but depreciated. So I was wondering if I could adapt my current implementation with ComponentPresentationAssembler by modifying the output format to rel and to publish to the database. But this don't seems to be the case. I have found some articles and I will try to see if I can use this concepts maybe in my code. The articles are erichuiza.blogspot.com/2013/10/… and erichuiza.blogspot.com/2013/07/… Fingers crossed :D Aug 7, 2020 at 9:54
1

I finally did it a little bit the ugly way by still publishing the ascx to file system like on the Tridion 2011 install.

I have replaced the ComponentPresentationAssembler code that was trying to load the componentpressentation with my own code. This code is now checking if the published ascx file exist and if that's the case then it loads the controller and write it to a string.

It can probably be improved and it's definitely not future proof.

The code looks like:

string content = "";
string virtualPath = $"~/dcp/pub{publicationID}/dcp/asp/dcp{componentTemplateId}_{componentID}.ascx";

if (File.Exists(HttpContext.Current.Server.MapPath(virtualPath)))
{
    Control control = page.LoadControl(virtualPath);
    if (control != null)
    {
       using (TextWriter myTextWriter = new StringWriter(new StringBuilder()))
       {
            using (HtmlTextWriter myWriter = new HtmlTextWriter(myTextWriter))
            {
                 control.RenderControl(myWriter);
                 content = myTextWriter.ToString();
             }
        }
    }
}
else
{
    ComponentPresentationFactory factory = new ComponentPresentationFactory(publicationID);
    ComponentPresentation cp = factory.GetComponentPresentation(TCMHelper.BuildComponentTCMId(componentID, publicationID), TCMHelper.BuildComponentTemplateTCMId(componentTemplateId, publicationID));
     if (cp != null)
     {
       content = cp.Content;
     }
}
0

I faced similar issue in the past.

Answer to your original problem DCPs published as REL in the database, and your DCP template output has a component link tag. which is not getting resolved in the web app.

Your case:

Pages – stored in the filesystem
DCPs – stored in DB
Web app dotnet uses CIL.

you should be able to get it working a Component Presentation in REL format with following settings in tcdl_conf.xml in deployer-service

    <!-- Uncomment any of the following lines to set the target language as a specific language -->
    <!--<Property Name="tcdl.page.target.language" Value="jsp" />-->
    <!--<Property Name="tcdl.page.target.language" Value="dotnet" />-->
    <Property Name="tcdl.target.language" Value="rel"/>
    <Property Name="tcdl.page.target.language" Value="dotnet" />

Refer to the SDL documentation reference for Enabling publishing of Pages with REL format Dynamic Component Presentations

I hope it helps

6
  • Thanks, Unfortunately this don't seems to solve my issue. I have added the property with dotnet and the templates are added correctly in the broker database with the correct tags. But when loading them with the ComponentPresentationAssembler the tridion:ComponentLink user controls in it are not executed. This seems to be something related to .net user controls so probably with jsp it is working correctly. Aug 7, 2020 at 9:45
  • @GlennFranquet Can you also keep that tcdl_conf.xml in content service and restart and try? I would expect on the fly content service will resolve the links when you try to access using ComponentPresentationAssembler API
    – Velmurugan
    Aug 7, 2020 at 9:48
  • @GlennFranquet In the deployer, I assume after you did update the tcdl_conf.xml and restarted and republished the DCP with REL format?
    – Velmurugan
    Aug 7, 2020 at 9:49
  • Ah sorry, the property updated wrongly in my answer, correct one <Property Name="tcdl.page.target.language" Value="dotnet" /> not <Property Name="tcdl.target.language" Value="dotnet" />
    – Velmurugan
    Aug 7, 2020 at 9:54
  • I tried a few combinations but unfortunately without any luck. Only difference is that when loading the page I see in the html tridion:componentlink or tcdl:componentlink. Every time I have restarted the combined deployer service, did a republish of page and components and restarted the site. Aug 7, 2020 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.