Demo TPL Plugins
|
#4923 |
|
|
Kaan
User is:
Posts: 2772
Meslek: Serbest Meslek
Age: 43
|
TPL Plugins
How to code plugins using a TPL file. Information This tutorial will walk you through on how to create plugins using tpl files rather than hard coded variables. The download link is at the bottom to get a running preview. Most of the tutorial is inside of the code. I find it's a lot easier learning to code plugins while looking at the code in notepad or your favorite text editor. However, here are some pictures that explain what this will teach. About the Plugin This plugin will simply just list 5 users from your website and show their username and user id. Pictures This plugin will walk you through on how to setup the look of the tpl file once you have the plugin all coded. It will teach you step by step with comments everywhere for each addition of code, and tell you what it's doing and how it works. This is the folder structure of the plugin. Pretty standard and basic. demo/inc/demo.main.inc.php : hp]<?PHP /* ==================== Seditio - Website engine Copyright Neocrome http://www.neocrome.net [BEGIN_SED] File=plugins/demo/inc/demo.main.inc.php Version=100 Updated=Jan-19-2007 Type=Plugin Author=Dyllon Description=How integrate tpl's into plugins [END_SED] ==================== */ if (!defined('SED_CODE') || !defined('SED_PLUG')) { die('Wrong URL.'); } /* ==================================================== ?imdi bu b?l?mde eklenti i?in biz 5 kullan?c? ?ekmekiyoruz veritaban?ndan. ==================================================== */ $sql = sed_sql_query("SELECT * FROM sed_users ORDER BY 'user_id' DESC LIMIT 5"); while ($row = mysql_fetch_array($sql)) { /* ==================================================== Mysql dan ?ekti?imiz 5 kullan?c?y? ekrana yazd?racag?z ve .tpl ye akracag?z. Tpl ye aktarmam?z i?in ?ncelikle etiketleri olu?turmam?z gerekiyor bunun i?in mysql dan ?ekti?imiz 5 kullan?c?n?n isimlerini ve id lerini al?yoruz. Dilerseniz di?er bilgilerinide alarbilirsiniz. Nas?lm?.? Mysql da yer alan user tablolar?ndan ilgili b?l?mlere bakarak. ?rnek: $row['user_msn'] msn adresi girilmi? ise ekranda g?rebilirsiniz tabiki etiket olu?turarak alabilirsiniz. Alttaki ?rne?e bakarak yapabilirsiniz. ==================================================== */ $t-> assign(array( "ROW_USER_NAME" => $row['user_name'], "ROW_USER_ID" => $row['user_id'] )); /* ==================================================== Burada .tpl ye yazd?rmam?z i?in MAIN kodunu plu?turuyoruz. Tpl de <!-- BEGIN: MAIN --> <!-- END: MAIN --> Aras?na <!-- BEGIN: ROW_USER --> <!-- END: ROW_USER --> Aras?na etiketlerimizi eklememizi s?yl?yor. Dilerseniz ROW_USER yerine her hangi bi?ey yazabilirsiniz. ==================================================== */ $t->parse("MAIN.ROW_USER"); /* ==================================================== ?imdi etiketlerimizi <!-- BEGIN: ROW_USER --> <!-- END: ROW_USER --> aras?na ekleyiniz. /plugins/demo/demo.tpl olu?turmal?s?n?z tabiki ?ncelikle ==================================================== */ } ?> demo.php : hp]<?PHP /* ==================== Seditio - Website engine Copyright Neocrome http://www.neocrome.net [BEGIN_SED] File=plugins/demo/demo.php Version=100 Updated=Jan-19-2007 Type=Plugin Author=Dyllon Description=How integrate tpl's into plugins [END_SED] [BEGIN_SED_EXTPLUGIN] Code=demo Part=main File=demo Hooks=standalone Tags= Minlevel=0 Order=10 [END_SED_EXTPLUGIN] ==================== */ if (!defined('SED_CODE') || !defined('SED_PLUG')) { die('Wrong URL.'); } /* ==================================================== First we need to let seditio know that we are going to be using a custom TPL in our plugin so it doesnt use the one in your skins folder. To do this add this to your code. Change the path to wherever you have your tpl file located. for this instruction it is: plugins/demo/demo.tpl ==================================================== */ $t = new Xtemplate("plugins/demo/demo.tpl"); /* ==================================================== Most plugins will include a language file, i have included one in this package. To use the language file simple add a variable such as $L['plugin_title'] and add the text to it. Review the language file inclded for more help ==================================================== */ $t-> assign(array( "PLUGIN_TITLE" => $L['plugin_title'], "PLUGIN_SUBTITLE" => $L['plugin_subtitle'] )); /* ==================================================== You do no have to use the language file if you do not want to, you can simple just add the variable right into the plugin and it will give you the same effect. Now, with this up top we have created an array. Within the array we assigned two tags, {PLUGIN_TITLE} and {PLUGIN_SUBTITLE} im sure you've seen these before. The output will look identical to whatever you put inside of the variable. Now we will switch it up by including multi level pages and ill show you how to use different style's of the tpl. ==================================================== */ require('plugins/demo/inc/demo.main.inc.php'); /* ==================================================== Personally i like to keep the main file as small as possible so I know where everything is easily. Therefore i store all of the data in the folder 'inc'. It might just be becuase im a neat freak when it comes to coding Now open /plugins/demo/inc/demo.main.inc.php to continue this tutorial. ==================================================== */ ?> demo.setup.php : hp]<?PHP /* ==================== Seditio - Website engine Copyright Neocrome http://www.neocrome.net [BEGIN_SED] File=plugins/demo/demo.setup.php Version=100 Updated=Jan-19-2007 Type=Plugin Author=Dyllon Description=How integrate tpl's into plugins [END_SED] [BEGIN_SED_EXTPLUGIN] Code=demo Name=Demo Plugin Description=How integrate tpl's into plugins Version=100 Date=Jan-19-2007 Author=Dyllon Copyright= Notes= SQL= Auth_guests=R Lock_guests=W12345A Auth_members=RW Lock_members=12345A [END_SED_EXTPLUGIN] ==================== */ if (!defined('SED_CODE')) { die('Wrong URL.'); } ?> demo/lang/demo.en.lang.php : hp]<?PHP /* ==================== Seditio - Website engine Copyright Neocrome http://www.neocrome.net [BEGIN_SED] File=plugins/demo/lang/demo.en.lang.php Version=100 Updated=Jan-19-2007 Type=Plugin Author=Dyllon Description=How integrate tpl's into plugins [END_SED] =================== */ if (!defined('SED_CODE')) { die('Wrong URL.'); } $L['plugin_title'] = "Demo Plugin"; $L['plugin_subtitle'] = "How integrate tpl's into plugins"; ?> demo.tpl : tml]<!-- BEGIN: MAIN --> <div id="title"> {PLUGIN_TITLE} </div> <div id="subtitle"> {PLUGIN_SUBTITLE} </div> <div id="main"> <table width="100%" class="cells"> <tr> <!-- BEGIN: ROW_USER --> <td>({ROW_USER_ID}) {ROW_USER_NAME}</td> <!-- END: ROW_USER --> </tr> </table> </div> <!-- END: MAIN --> |
Emlak, Oto Galeri, Rent A Car, ?iir, Edebiyat Script Sipari?lerinizi Verebilirsiniz. Detaylar ??in: kaan@ntka.org Seditio 170 ?ndir Capte M?zik ?ndir Seditio Toolbar ?ndir |













