4

I'm using Page.Title in my legacy VBscript component dynamic template as below:

WriteOut "Component '<b>" & EscapeXMLCharacters(iComp.title) & "</b>', based on Schema '<b>" & EscapeXMLCharacters(iComp.schema.title) & "'</b>, test '<b>" & Page.Title& "'</b></td></tr>" & vbLf

This works fine when i preview the page, but when i publish the page, it fails with following error:

Error 424 occurred while rendering the Component Presentation (LegacyComponent:LegacyComponentTemplate): Object required: 'Page' (source: WriteOut "Component '" & EscapeXMLCharacters(iComp.title) & "', based on Schema '" & EscapeXMLCharacters(iComp.schema.title) & "', Tst '" & test & "', test2 '" & Page.Title& "'" & vbLf).

However, when I set the component template as static, publish works fine.

Have any one come across similar issue?

2 Answers 2

4

In either the 2009 or 2011 releases the rendering process when publishing pages containing DCPs was "optimized" so that the DCPs were rendered separately outside the context of the page rendering. This meant that if you published a whole bunch of pages in one go, and several contained the same DCP, this DCP would only be rendered once, whereas previously it would be rendered several times, each with a different page context. As preview is only ever for one item at a time, I guess there is still a page context for this rendering process.

The side effect of this was that any code in your DCP which accessed the page would break - which is the effect that you are seeing.

It is not good practice to couple a DCP to the page in your component template for this very reason (what happens if you have the DCP on two pages - which is the "right" one?) so I would suggest that you take an audit of all the code that does this, and see if its really needed (the example you show looks like test code anyway).

2

I'm not 100% sure why it works in preview for you (I expect you are previewing the Page, not just the Component, but there's still something a little funky going on there), but remember that Dynamic Component Templates are rendered separately from the Page (think as if they are HTML/Code snippets, not full pages) and deployed separately to the Broker database.

There is no Page for your code to access.

You could, for example, publish just your Component and it will be rendered using just your Dynamic Component Template and sent to the Deployer. No Page will be rendered. If you are publishing your Page, then you have presumably allowed the Dynamic Component Template to be used on a page as if it was embedded, but the same principle applies. Tridion will render the ComponentPresentation separately.

1
  • 1
    Even when rendered with a page the page object should not be available, but thanks to a bug in 5.3 (!) where this was possible we had to keep compatibility and allow access to page objects from DCPs when rendered in a page. Rendered dynamically there is no page object, and this has all to do with common sense.
    – Nuno Linhares
    Nov 19, 2014 at 22:33

Your Answer

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

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