Activity Stream
48,167 MEMBERS
64189 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1.     
    #1
    Member
    Website's:
    Doxsters.net

    Default 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
    timtamboy63 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"

  2.   Sponsored Links

  3.     
    #2
    Member
    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);

  4.     
    #3
    Member
    Website's:
    Doxsters.net
    would 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"

  5.     
    #4
    Member
    You'd have to check if the file exists, if you wanted to do that possibly?

  6.     
    #5
    Member
    Website's:
    Doxsters.net
    Not 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"

  7.     
    #6
    Banned
    Why dont ya use Smarty instead than creating your own?

  8.     
    #7
    Member
    Maybe, because he doesn't want to

  9.     
    #8
    Member
    Website's:
    Doxsters.net
    Yeah, 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"

  10.     
    #9
    Banned
    Ohh Great Code your own PHP Parser so that u know how it all works

  11.     
    #10
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    dont 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


Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Selling] MP3 Search Engine Script - Promotion Code %50 off for limited time!
    By tcmcem in forum Marketplace (Buy, Sell and Trade)
    Replies: 0
    Last Post: 4th Aug 2012, 09:54 AM
  2. [Selling] MP3 Search Engine Script - Promotion Code %50 off for limited time!
    By tcmcem in forum Completed Transactions
    Replies: 1
    Last Post: 28th Jul 2012, 03:34 AM
  3. parse if's in my template engine?
    By timtamboy63 in forum Web Development Area
    Replies: 6
    Last Post: 28th Jul 2010, 01:37 AM
  4. [Selling] Datalife Engine 8.5 Translated Template
    By Last Word in forum Completed Transactions
    Replies: 0
    Last Post: 9th Jul 2010, 09:34 AM
  5. How to translate datalife engine template?
    By desibreaker in forum Webmaster Discussion
    Replies: 6
    Last Post: 21st Dec 2009, 03:13 AM

Tags for this Thread

BE SOCIAL