Page 1 of 1

parsing sql data on a content management system

Posted: Fri Feb 11, 2005 6:37 am
by fpj05
At the moment my cms system that I've built works by taking the main content from a database and putting it in the template. This is fine generally but I've hit a small problem...

I want to have php code in some of the pages. Mainly to generate some forms and process them. I want the sql content entry simply to be as follows:

content content content {addform(enquiry)} content content content

When the page loads it should simply display the content, but anything inside the {} it should process.

For now {addform} could simply be replaced by some html code (text), but in the future I'll need it to be able to pass parameters, e.g. addform(enquiry) will be replaced by an enquiry form, addform(prices) will be replaced by a price form etc.

Some pointers as to how to do this would be very much appreciated. Thanks.

Posted: Fri Feb 11, 2005 6:51 am
by timvw
so basically you are trying to reinvent php? you can read the multiple discussions on template engines in this forum and draw your own conclusions :)

Posted: Fri Feb 11, 2005 6:56 am
by djot
-

Code: Select all

<?php

  function Name()
  &#123;
  	  return "fpj05";
  &#125;

  $output = "Hello, my name is &#123;name&#125;.";
  $output = str_replace("&#123;name&#125;", Name(), $output);

  echo $output;
  
?>

djot
-

Posted: Fri Feb 11, 2005 7:06 am
by fpj05
stupid me!

I think the cold I have has reduced my ability to see the most obvious things!

I don't think it quite solves the parameter problem - but that's not so important at the moment.

Many thanks