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.

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

  1. Smarty php template Engine
  2. Smarty Modifier dan Fungsi Itu Apa sihhh…?
  3. membuat symlink shortcut ala linux
  4. show hidden file XP tidak berfungsi bisa jadi VIRUS
  5. Menyimpan Gambar di Database MySql dengan PHP

About The Author

admin

Seorang penelusur, pembongkar dan peramu informasi ala mbah google dot com

2 Comments

  1. qu4ck says:

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

  2. admin says:

    suwun frendsss

Leave a Reply