General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 11th, 2002, 09:27 PM
Kiwi Kiwi is offline
Guru-in-training
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Not where I want to be...yet!
Posts: 38 Kiwi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Parsing code snippets from database

Problem:
I'm using a template-based system to display pages. What I want to do is make the system extensible by adding objects to a database and then retrieve the objects and output them using a page template.

The workflow will look something like this:
Call function page
function page reads template page
function page calls db snippet
function page parses template page and inserts code snippet
output page parses snippet.

So what I want to do is have the user access http://www.domain.com/display.php?id=nnnn
display.php reads displaytemplate.html
display.php finds <<codesnippetid>> and retrieves the corresponding snippet.
replaces <<codesnippetid>> with the code
writes this to the browser in a way that allows the snippet to be parsed then.

Does anyone have any idea how I could accomplish this easily ?
I have a basic framework in place, but my resulting page displays the code instead of the parsed code.


Last edited by Kiwi : September 11th, 2002 at 09:45 PM.

Reply With Quote
  #2  
Old September 11th, 2002, 10:08 PM
Joe4JC Joe4JC is offline
The name's Joe. Yours?
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Lurking in the shadows...
Posts: 147 Joe4JC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Yeah, id like info about this too - for the same reason Right now I am using strreplace() to replace the code, but that defeats the purpose doesn't it? or maybe im wrong?

Cheers,
Joe of 4Life
__________________
Check out 4Life today!

Reply With Quote
  #3  
Old September 12th, 2002, 03:05 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
hmm, try creating a class file that handles the templates, create a function to retrive the file name, one to set the parameters and one to create the page.

Reply With Quote
  #4  
Old September 12th, 2002, 04:49 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Kiwi,

Why not give a template system a try? No need to re-invent the wheel... I use patTemplate for my development, and find it to be an incredible system!

There's also Smary, but I haven't used it yet.

Check them both out and decide for yourself which is the better system for you.
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #5  
Old September 12th, 2002, 06:42 PM
Kiwi Kiwi is offline
Guru-in-training
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Not where I want to be...yet!
Posts: 38 Kiwi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Quote:
Originally posted by FrankieShakes
Kiwi,

Why not give a template system a try? No need to re-invent the wheel... I use patTemplate for my development, and find it to be an incredible system!

There's also Smary, but I haven't used it yet.

Check them both out and decide for yourself which is the better system for you.


Thanks, Frankie...funny enough I'd just been looking at smarty and was thinking it may be the best approach, but I'll have a look at patTemplate too.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Parsing code snippets from database


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT