Memulai Membuat Website Smarty dengan Hello World!!

Kinilah saatnya kita mulai start untuk membuat website dengan smarty, satu langkah kecil menampilakn teks Hello World dengan smarty.

Persiapan

  1. Pastikan di Komputer anda telah terinstall PHP & Apache + Mysql biasanya pakai XAMPP atau APP Server
  2. Download Smarty disini http://www.smarty.net/download.php

kebetulan kali ini saya menggunakan App Server untuk menjalankan script php smarty nya.

Tahapan

  1. Extract Smarty pada folder www kebetulan saya membuat folder sendiri yaitu smarty jadi strukturnya dibawah folder www ada smarty dst (www/smarty/)
  2. Buat satu folder helloWorld di bawah folder smarty, kenapa buat folder? karena kedepan supaya mudah untuk membuat applikasi lainnya.
  3. Buat 2 folder dibawah folder helloWorld yaitu folder templates bertujuan untuk menyimpan file template dan folder templates_c bertujuan untuk menyimpan cache template smarty
  4. dibawah folder helloWorld buat 1 file index.php di isi dengan
    <?php
    /**
    * @author Hadi Suwantoro
    */

    require ‘../Smarty-2.6.26/libs/Smarty.class.php’;

    $smarty = new Smarty;
    $smarty->assign(‘helloworld’,'Hello World!’);
    $smarty->display(‘index.tpl’);
    ?>

  5. Kemudian di dalam folder templates buat satu file dengan nama index.tpl dan isi dengan
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
    <html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>

    <head>
    <meta http-equiv=”content-type” content=”text/html; charset=iso-8859-1″ />
    <meta name=”author” content=”Superman” />

    <title>{$helloworld}</title>
    </head>

    <body>

    {$helloworld}

    </body>
    </html>

  6. Selanjutnya akses file index.php melalui browser alamatnya http://localhost/smarty/helloWorld/index.php
  7. Selesai… maka anda akan mendapati tampilan utama Hello world

Selamat mencoba.

VN:F [1.1.4_465]
Rating: 9.0/10 (1 vote cast)

Incoming search terms for the article:

Share/Save/Bookmark

Related posts:

  1. Smarty php template Engine Bagi yang sudah kenal Smarty ya monggo[1] dilewatin saja, tapiiiii...
  2. Smarty Modifier dan Fungsi Itu Apa sihhh…? Sebelumnya anda harus mencoba Smarty dulu dengan mendownload dan menjalankannya...
  3. membuat symlink shortcut ala linux Symlink sama dengan shortcut jika kita berada pada sistem...

Related posts brought to you by Yet Another Related Posts Plugin.

2 Comments

  1. qu4ck says:

    Adah yg lebih simple Ringan hanya 1 class template aja Lumayan lg… Namanya XTemplate….. Kapan2 tak bahas kang… :D

    VA:F [1.1.4_465]
    Rating: 0.0/5 (0 votes cast)
  2. admin says:

    suwun frendsss

    VN:F [1.1.4_465]
    Rating: 0.0/5 (0 votes cast)

Leave a Reply