parsing sql data on a content management system

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fpj05
Forum Newbie
Posts: 2
Joined: Fri Feb 11, 2005 6:17 am

parsing sql data on a content management system

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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 :)
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

Post 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
-
fpj05
Forum Newbie
Posts: 2
Joined: Fri Feb 11, 2005 6:17 am

Post 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
Post Reply