1

Hi I've had some experience with a web design company and I noticed that they where drawing the data from the MySQL table with what they called template tags, which goes as follows;

%FIRSTNAME% %COMPANY_NAME%

How does something like that work? and how is it achieved?

Its really interesting to me but just kept slipping my mind to ask how that works.

Any one have any ideas? Is this PHP or is it more like javascript or something?

user0129e021939232
  • 6,205
  • 24
  • 87
  • 140
  • It's likely to be PHP or some other server-side language. Rather than putting too much code in the HTML file, they've chosen to put in small tags that are replaced when the page is rendered. Smarty and Twig work like this, and have all sorts of features to help with screen rendering. That said, some people take the view that PHP is in itself a decent template renderer itself, and that a separate library is unnecessary. – halfer Sep 05 '13 at 12:51
  • 3
    This looks like some kind of templating engine, which often at their core are based on [`preg_replace_callback()`](http://php.net/preg-replace-callback). But IMO these things are completely unnecessary, PHP has it's own templating format that works perfectly well. – DaveRandom Sep 05 '13 at 12:51
  • i recommend reading this book "cms design using php and jquery" this is the link : http://bookos.org/book/1002505/6f62bb – mostafa khansa Sep 05 '13 at 12:51
  • Related: http://stackoverflow.com/questions/18197348/replacing-variables-in-a-string/18213633 – DaveRandom Sep 05 '13 at 12:56
  • @mostafakhansa How is that related to the way a templating engine works? – DaveRandom Sep 05 '13 at 12:58

1 Answers1

0

@halfer @daveRandom thanks guys, sounds interesting will read further into smarty and twig as well as preg_replace_callback()

I guess they use these templating format to save a lot of time as they manage over 1500+ sites for one client so reduces the amount of code they would have to use and makes it easier to call generic templates.

user0129e021939232
  • 6,205
  • 24
  • 87
  • 140