Skip to main content
Brad Lawryk
Legend
February 11, 2010
Question

Recordsets in Templates

  • February 11, 2010
  • 2 replies
  • 435 views

Trying to get used to templates ...

Is there a way to apply a recordset to a template file since it is content that appears on all pages? (PhP/MYSql)

Thanks Brad

This topic has been closed for replies.

2 replies

David_Powers
Inspiring
February 12, 2010

Templates are not designed to be used to propagate server-side code to child pages. If you look at the code in the head of a child page, you'll see the following immediately after the DOCTYPE declaration:

<!-- InstanceBegin template="/Templates/template_name.dwt.php" codeOutsideHTMLIsLocked="false" -->

This allows you to add server behaviors to child pages.

Templates work on the principle of locking code that is propagated to all pages. Since most server behavior code is placed outside the HTML, the areas above the DOCTYPE declaration and below the closing </html> tag need to be editable.

If you want a recordset to appear on every child page, you can do so by adding the following anywhere inside the head of the dwt page:

<!-- TemplateInfo codeOutsideHTMLIsLocked="true" -->

That will lock the areas above and below the HTML. Be warned, though, that locked means locked. Your recordset will be in every child page, but you won't be able to add any other server behaviors to the page if they need to add code above the DOCTYPE declaration.

Brad Lawryk
Legend
February 11, 2010

I should clarify that it is in the .dwt file that I can't add a recordset ... the php files are fine.

Brad