Results 1 to 2 of 2

Thread: Colfusion Template Engine Component

  1. #1
    Join Date
    Nov 2001
    Location
    Johor
    Posts
    772
    Rep Power
    229

    Colfusion Template Engine Component

    Assalamualaikum!!

    Hoh lama beno rasa teman tak post kat sini. Nah hari ni teman saje nak post coldfusion template engine component kat sini untuk dikongsi bersama2. Teman buat component ni masa teman ngajar coldfusion kat melaka.

    Component ni boleh fungsinya lebih kurang xtemplate (php). Tapi ni adaptasi ke coldfusion. Walaupun coldfusion ni tags language ada gak la designer2 teman padam cftags ni. Dia kata ni bukan html punya tags. Hehe...

    Tengok2 lah sape2 coldfusion developer tu. Ha ni teman nak ingatkan ni bukan framework arr. Component ni cuma salah satu dari MVC (Model View Controller) iaitu View je. Hehe...

    DOWNLOAD TEMPLATECFC
    Versi: 1.8.8

    Example 1 (simple assign)
    user.cfm
    Code:
    <cfset name = "Muhammad Hamizi Jaminan">
    <cfset nickname = "hymns">
    
    <cfset tpl = createobject("component", "templatecfc")>
    <cfset tpl.init("user.html")>
    
    <cfset tpl.assign("name", name)>
    <cfset tpl.assign("nickname", nickname)>
    
    <cfset output = tpl.parse("true")>
    
    <cfoutput>#output#</cfoutput>
    user.html
    HTML Code:
    <head>
    <body>
    My name is {fullname}. You also can call me {nickname}
    </body>
    </html>
    Browser Ouput
    My name is Muhammad Hamizi. You also call me hymns

    Example 2 (Query & Array)
    query.cfm
    Code:
    <cfquery name="myquery">
    select id, username, phone, email from tbl_users
    </cfquery>
    
    <cfset myarray = arraynew(1)>
    <cfset myarray[1] = "ice tea">
    <cfset myarray[2] = "hot tea">
    <cfset myarray[3] = "hot coffee">
       
    <cfset tpl = createobject("component", "templatecfc")>
    <cfset tpl.init("query.html")>
    
    <cfset tpl.assign("data", myquery)>
    
    <cfset tpl.assign("drink", myarray)>
    
    <cfset output = tpl.parse("true")>
    
    <cfoutput>#output#</cfoutput>
    query.html
    HTML Code:
    <head>
    <body>
    <h3>User List</h3>
    <table border="1" width="100%">
        <tr>
            <td>ID</td>
            <td>Username</td>
            <td>Phone</td>
            <td>Email</td>
        </tr>
        <!-- BEGIN : data -->
        <tr>
            <td>{data.id}</td>
            <td>{data.username}</td>
            <td>{data.phone}</td>
            <td>{data.email}</td>
        </tr>
        <!-- END : data -->
        <tr>
            <td colspan=4>Total Record: {data.recordcount}</td>
        </tr>       
    </table>
    
    <h3>Favourite Drink</h3>
    <table border=1>
        <!-- BEGIN : drink -->
        <tr>
            <td>{drink}</td>
        </tr>
        <!-- END : drink -->   
    </table>
    </body>
    </head> 
    Browser Output
    User List
    ---------------------------------------
    | ID | Username | Phone | Email |
    ---------------------------------------
    | 1 | hymns | 1231312 | user@user.com |
    ---------------------------------------
    | 2 | johndoe | 1231231 | user2@user.com |
    ---------------------------------------
    | Total Record: 4 ; ; |
    ---------------------------------------

    Favourite Drink
    ice tea
    hot tea
    hot coffee


    Component ni gak boleh guna vars CGI direct terus. Contoh untuk dapatkan ip gunakan tag {CGI.REMOTE_ADDR} atau {CGI.SCOPE} untuk lain-lain coldfusion cgi scope.

    Kalau rasa nak fancy2 skit ala2 smarty, teman buat gak function ni untuk BESARKAN HURUF {tagname|upper} atau huruf kecil {tagname|lower}

    Untuk sample-sample lain boleh tengok dalam package tu.

    Kalau teman-teman kat WM ni ade idea2 nak tambah post2 la kat sini yer. Teman buat ni saja suka2. (sebenarnya teman lebih suka coding PHP tapi banyak yang dah siap. guna ajer)

    DOWNLOAD TEMPLATECFC
    I hate when:

    vBulletin Message:
    Sorry! The administrator has specified that users can only post one message every 60 seconds

  2. #2
    Join Date
    Dec 2008
    Location
    KL
    Posts
    12
    Rep Power
    0

    cool man!

    cool man! but i still prefer the CFWheels way to write application
    btw, i wonder how many CF programmer like you n me in Malaysia?

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. joomla component
    By harrysuke in forum Webmaster Tools
    Replies: 2
    Last Post: 26-08-2009, 09:31 AM
  2. Describe Your JOOMLA Component / Module
    By vedee2006 in forum Website Design
    Replies: 3
    Last Post: 12-04-2008, 12:43 PM
  3. Template for SALE from $130 onwards! - We also have OS Commerce template!
    By certify in forum Other Webmaster-related Services and Promotion
    Replies: 3
    Last Post: 24-04-2007, 09:13 AM
  4. Flash MX Component UI?
    By Gemp-X in forum Website Design
    Replies: 9
    Last Post: 29-05-2002, 02:22 AM
  5. template
    By nuha in forum Website Programming
    Replies: 0
    Last Post: 02-05-2002, 11:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30