Results 1 to 10 of 16
-
26th Jul 2010, 06:22 AM #1OPMemberWebsite's:
Doxsters.netTrying to code my own template engine.
Ive got the basics working, it replaces variables.
Now what I need it to do is replace for example {header} with the contents of header.tpl. How would I do that? I'm thinking of trying to use preg_match to do it, but im not too sure how to use it, etc.
Is this the best way to do it?
Thanks,
timtamtimtamboy63 Reviewed by timtamboy63 on . Trying to code my own template engine. Ive got the basics working, it replaces variables. Now what I need it to do is replace for example {header} with the contents of header.tpl. How would I do that? I'm thinking of trying to use preg_match to do it, but im not too sure how to use it, etc. Is this the best way to do it? Thanks, timtam Rating: 5
Need a Designer/Web Developer? Click Me
MSN: PM me for it.
Email(Preferred):timtamboy63@gmail.com
"Power Corrupts. Absolute Power Corrupts Absolutely"
-
26th Jul 2010, 06:26 AM #2Member
What about:
PHP Code:<?php
str_replace('{header}', "<?php include('header.tpl'); ?>", $file_contents);
// Or this ;)
preg_replace('\{header}\\', "<?php include('header.tpl'); ?>", $file_contents);
-
26th Jul 2010, 06:32 AM #3OPMemberWebsite's:
Doxsters.netwould defeat the purpose, i'd have to define everything. Im trying to get it done dynamically.
eg they could go {somenamehere} and it would load somenamehere.tpl into there
btw ive almost got it working, im just trying to work out recursion now
Need a Designer/Web Developer? Click Me
MSN: PM me for it.
Email(Preferred):timtamboy63@gmail.com
"Power Corrupts. Absolute Power Corrupts Absolutely"
-
26th Jul 2010, 06:33 AM #4Member
You'd have to check if the file exists, if you wanted to do that possibly?
-
26th Jul 2010, 07:22 AM #5OPMemberWebsite's:
Doxsters.netNot really, anyway ive got an idea ima try right now, using a while loop hopefully it works
Need a Designer/Web Developer? Click Me
MSN: PM me for it.
Email(Preferred):timtamboy63@gmail.com
"Power Corrupts. Absolute Power Corrupts Absolutely"
-
26th Jul 2010, 07:27 AM #6Banned
Why dont ya use Smarty instead than creating your own?
-
26th Jul 2010, 07:32 AM #7Member
Maybe, because he doesn't want to
-
26th Jul 2010, 08:45 AM #8OPMemberWebsite's:
Doxsters.netYeah, I wanna be able to code my own. While I don't mind learning from other people's scripts, I prefer coding and using my own, simply because I don't have to learn their coding stylem and instead I know exactly how it all works.
Need a Designer/Web Developer? Click Me
MSN: PM me for it.
Email(Preferred):timtamboy63@gmail.com
"Power Corrupts. Absolute Power Corrupts Absolutely"
-
26th Jul 2010, 08:50 AM #9Banned
Ohh Great Code your own PHP Parser so that u know how it all works
-
26th Jul 2010, 12:43 PM #10MemberWebsite's:
litewarez.net litewarez.com triniwarez.comdont do it lol.
Read my tutorial, your trying to reinvent the wheel by using {} or []... just use the slandered php tags and read my template engine tutorial.Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
[Selling] MP3 Search Engine Script - Promotion Code %50 off for limited time!
By tcmcem in forum Marketplace (Buy, Sell and Trade)Replies: 0Last Post: 4th Aug 2012, 09:54 AM -
[Selling] MP3 Search Engine Script - Promotion Code %50 off for limited time!
By tcmcem in forum Completed TransactionsReplies: 1Last Post: 28th Jul 2012, 03:34 AM -
parse if's in my template engine?
By timtamboy63 in forum Web Development AreaReplies: 6Last Post: 28th Jul 2010, 01:37 AM -
[Selling] Datalife Engine 8.5 Translated Template
By Last Word in forum Completed TransactionsReplies: 0Last Post: 9th Jul 2010, 09:34 AM -
How to translate datalife engine template?
By desibreaker in forum Webmaster DiscussionReplies: 6Last Post: 21st Dec 2009, 03:13 AM
themaCreator - create posts from...
Version 3.52 released. Open older version (or...