webJestic.NET

Creating Dynamic Smarty Variables in Delphi for PHP

preview image

One of the first things you’ll notice when you begin working with Smarty Templates in the Delphi for PHP environment is that it’s not obvious how you can include custom or dynamic smarty variable tags into your template from Delphi for PHP.

This video was created to demonstrate exactly how to get dynamic smarty variables into your smarty templates and display the correct variable information. The main thing to know and understand is, that the VCL in Delphi for PHP has a certain time it executes the Smarty Engine events.

To access the correct time and place to assign your variables is to use the Forms->OnTemplate event and access the smarty object through the provided $params. In this video I’ve created 3 dynamic smarty tag variables.  $MyTitle, $MyDescription, and $MyKewords.  I assign the values of these variables in Delphi for PHP and placed them in the HTML smarty template.

  1. function Unit1Template($sender, $params)
  2. {
  3.         $template = $params[‘template’];
  4.         $template->_smarty->assign(‘MyTitle’, ‘My Custom Page Title’);
  5.         $template->_smarty->assign(‘MyDescription’, ‘My Custom description…’);
  6.         $template->_smarty->assign(‘MyKeywords’, ‘keyword 1, Smarty Keyword’);
  7. }

If you’ve found this video posting useful, you might also be interested in the video posting that extends this lesson: Creating Editable Forms for Smarty Templates in Delphi for PHP.

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

webJestic.NET