Zack Notes

Joomla 1.5 Template တစ္ခု ပုံေဖာ္ၾကည့္ျခင္း

Written by Zack

ကြၽန္ေတာ္ ဒီ Post မွာ Joomla 1.5 Template တစ္ခုကို ဘယ္လို create လုပ္မလဲ ဆိုတာကို ကြၽန္ေတာ္ သိထား သေလာက္ ေရးပါမယ္။ အရင္ဆုံးေတာ့ Joomla ကိုဘယ္လို Install လုပ္မယ္၊ Admin Panel ကေန Template ဘယ္လို ေျပာင္းမယ္ ဆိုတာေတြကိုေတာ့ သိထားဖို႔ လိုပါတယ္။ တကယ္လို႕ အဲဒါေတြကို သိခ်င္ရင္ေတာ့ ကြၽန္ေတာ့္ Joomla CMS Post အေဟာင္း ေတြထဲမွာ ရွိပါတယ္။ ကြၽန္ေတာ့္ Joomla 1.0 Post ေတြကို ဖတ္ျပီး စမ္းေနမွာ စိုးလို႕  ဖတ္တဲ့သူေတြ အဆင္ေျပ ေစဖို႔ Post Title ေတြမွာ Joomla 1.0 or Joomla 1.5 စသည္ျဖစ္ ထည့္ေပးထားပါတယ္။ ခုမွ Joomla ကိုစလုပ္မယ့္ သူေတြကို အၾကံျပဳခ်င္တာက ခုခ်ိန္မွာ Joomla က 1.6 ကိုေတာင္ သြားေနျပီ ျဖစ္လို႕ အနည္းဆုံး Joomla 1.5 ကိုစကိုင္ သင့္ပါတယ္။ Okay ဗ်ာ စလိုက္ၾက ရေအာင္။ ဘာမွ မလုပ္ခင္ Joomla 1.5 ကို install လုပ္ထားတယ္လို႕ ယူစလိုက္မယ္ဗ်ာ။

Joomla Default Template ကိုေလ့လာ ၾကည့္ျခင္း

အရင္ဆုံး Joomla 1.5 default template ကိုဖြင့္ၾကည့္မယ္ ဆိုရင္ Default Template ၃ခု ကိုေတြ႕ ရမယ္။


ေျပာမယ္ ဆိုရင္ေတာ့ Joomla root folder ေအာက္မွာ Template အတြက္ templates ဆိုတဲ့ folder ရွိေနျပီး Front-End မွာ သုံးမယ့္ template ေတြအားလုံး အဲဒီ Folder ေအာက္မွာ ရွိပါတယ္။

Template မ်ားကို Back-End မွ manage လုပ္ျခင္း

ခုန ကြၽန္ေတာ္ေျပာတဲ့ templates ေတြထဲက ဘယ္ template ကိုသုံးမယ္ ဆိုတာကို ေရြးခ်ယ္ေပးခ်င္ တယ္ဆိုရင္ေတာ့ Extension >> Template Manager ကေန လုပ္ေဆာင္ေပးႏိုင္ပါတယ္။

Template တစ္ခု တည္ေဆာက္ျခင္း

Article Manager ထဲကေန Article တစ္ခုကို စမ္းဖို႔ create လုပ္ျပီး Front End ကေနၾကည့္မယ္ဆိုရင္ ဒီလိုျမင္ ရပါမယ္။ ဒါကေတာ့ rhuk_milkyway ဆိုတဲ့ default template ကိုသုံးထာတာ ျဖစ္ပါတယ္။


အဲလိုမ်ိဳး template တစ္ခုကို လုပ္ခ်င္တယ္ ဆိုရင္ေတာ့ templates folder ထဲကိုသြားျပီး mytemplate_tut ဆိုျပီး folder အသစ္ တစ္ခု အရင္ေဆာက္ လိုက္ပါမယ္။ေနာက္တစ္ဆင္ အေနနဲ႔ ကေတာ့ mytemplate_tut folder ထဲမွာ index.php နဲ႔ templateDetails.xml files ႏွစ္ခု create လုပ္လိုက္ပါ။ Joomla Template တစ္ခု လုပ္ဖို႔ တကယ္ အခရာက်တာက အဲဒီ ၂ files ပဲျဖစ္ပါတယ္။

templateDetails.xml ကေတာ့ ကိုယ့္ template မွာသုံးမယ့္ module position, images, files ေတြအျပင္ template မွာ author, copyright, version စတာေတြကိုပါ ထည့္ေပးႏိုင္ တယ္ ဗ်ာ။ ေျပာမယ္ဆိုရင္ေတာ့ ကိုယ့္ template ရဲ႕ Setting File ပဲေပါ့။ Template ကို install လုပ္ရင္ အဲဒီ XML File ကေနစျပီး run တာျဖစ္ပါတယ္။

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE install PUBLIC "-//Joomla! 1.5//DTD template 1.0//EN" "http://www.joomla.org/xml/dtd/1.5/template-install.dtd">
<install version="1.5" type="template">
    <name>mytemplate_tut</name>
    <creationDate>02/09/10</creationDate>
    <author>Zack</author>
    <authorEmail>joomzack@gmail.com</authorEmail>
    <authorUrl>http://www.zack-notes.net</authorUrl>
    <copyright></copyright>
    <license>GNU/GPL</license>
    <version>1.0.0</version>
    <description>TPL_RHUK_MILKYWAY</description>

    <positions>
        
        <position>breadcrumb</position>
        <position>left</position>
        <position>right</position>
        <position>top</position>
        <position>footer</position>

    </positions>

</install>


index.php ကေတာ့ ကိုယ္ template ထဲမွာပါမယ့္ Layout ေတြ၊ module position ေတြအျပင္ ဘယ္ modules အတြက္ ဘယ္ CSS ကိုေခၚမယ္ ဘယ္ image ကိုထည့္မယ္ စတာေတြ အတြက္ ထည့္ေပး ထားတာ ျဖစ္ပါတယ္။ index.php ကိုဖြင့္ျပီး code ေလးနဲနဲေရး လိုက္ပါမယ္။

<!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="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >  
<head>  
<jdoc:include type="head" />  
</head>  
 
<body>  
 
<jdoc:include type="component" />  
 
</body>  
</html>


အဲဒီ Code ကိုၾကည့္မယ္ ဆိုရင္ <jdoc:include type="head" /> ကေတာ့ Browser မွာ Title ေတြေပၚဖို႔ အတြက္ပါ။ ေနာက္တစ္ခု ကေတာ့ <jdoc:include type="component" /> ပါ။ အဲဒါကေတာ့ content ေတြကို ျပခ်င္လို႕ include လုပ္တာ ျဖစ္ပါတယ္။ ဒါဆိုရင္ ကြၽန္ေတာ္တို႔ Back-End ကေန ခုလုပ္ထားတဲ့ template ေလးကို ေျပာင္းျပီး ျပန္ run ၾကည့္ရေအာင္။

ဒီလိုမ်ိဳး ျမင္ရတယ္ ဆိုရင္ေတာ့ mytemplate_tut ကိုေျပာင္းသြားျပီး ျဖစ္ပါတယ္။


Template တြင္ module position မ်ားကို ေနရာခ်ျခင္း

module position ေတြကို ေနရာ မခ်ခင္ ကိုယ့္ template မွာ module position ေတြကို templateDetails.xml ထဲမွာ သတ္မွတ္ထားခဲ့တာ မွတ္မိမယ္ ထင္ပါတယ္။အဲဒီ module positions ေတြကို ထည့္ခ်င္ရင္ေတာ့ ဒီ standard ကို လိုက္နာဖို႔ လို႕ပါတယ္။

<jdoc:include type="modules" name="position_name" />

ဒီေတာ့ဗ်ာ left နဲ႔ footer module positions ႏွစ္ခုကို ထည့္ေပးၾကည့္ရေအာင္။ index.php မွာ code ကို နဲနဲ ျပင္လိုက္ပါမယ္။

<!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="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >  
<head>  
<jdoc:include type="head" />  
</head>  
 
<body>  
 
<jdoc:include type="component" />  
   <jdoc:include type="modules" name="left" />  
<jdoc:include type="modules" name="footer" />  
</body>  
</html>



ဒါဆို ခုနလုပ္ထားတဲ့ footer position ကို module တစ္ခုထားၾကည့္ဖို႔ Extensions >> Modules Manager ကေန footer module ကို module position မွာ footer ေပးျပီး enable လုပ္ေပး လိုက္ပါ။

Front-End ကေန footer module ကိုသြားျပန္ၾကည့္မယ္ ဆိုရင္ေတာ့


Module Position အတိုင္း Home menu က left မွာရွိေနေသာ္လည္း CSS ေတြမထည့္ ရေသးလို႕ အထဲဝင္ ေနတယ္လို႕ ထင္ႏိုင္ပါတယ္။

Template တြင္ CSS မ်ားေပါင္း ထည့္ၾကည့္ျခင္း

ဟုတ္ျပီဗ်ာ ဒီေတာ့ ထင္သာျမင္သာေအာင္ CSS ေတြလိုက္ထည့္ျပီး ျပင္ၾကည့္လိုက္ရေအာင္။

* { 
    padding: 0; 
    margin:0; 
    } 
ul { 
    list-style:none; 
    }
.float_right{
    float: right;
   
}
.float { 
    float: left; 
    } 
.clear { 
    clear: both; 
    } 
#container { 
    width:960px; 
    margin: auto; 
    } 
#header { 
    background-color:#659EC7; 
    height: 150px; 
    } 
#content { 
    width: 660px; 
    text-align: center; 
 
    } 
#sidebar_left { 
    text-align: center; 
    background-color:#95B9C7; 
    width: 150px; 
    } 
#sidebar_right { 
    background-color:#95B9C7; 
    width: 90px; 
    } 
#footer { 
    background-color:#98AFC7; 
    text-align:center; 
    }


ဒီ code ေလးကို mytemplate_tut folder ေအာက္မွာ CSS လို႕ folder ေလးထပ္ေဆာက္ျပီး template.css အေနနဲ႔ သိမ္းထားလိုက္ပါ။

ဒါဆိုရင္ေတာ့ ဒီ CSS ေတြကို index.php ထဲကေန ျပန္ေခၚသုံးၾကည့္ဖို႔ code ကိုနဲနဲ modify လုပ္လိုက္ပါမယ္။

<!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="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >  
<head>  
<jdoc:include type="head" />  
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/mytemplate_tut/css/template.css" type="text/css" />  
</head>  
 
<body>  
<div id="container">  
    <div id="header"> Header </div>  
    <div id="sidebar_left" class="float"><jdoc:include type="modules" name="left" /></div>  
    <div id="content" class="float">  
        <jdoc:include type="component" />  
    </div>  
    <div id="sidebar_right"class="float">Right sidebar</div>  
    <div id="footer" class="clear"><jdoc:include type="modules" name="footer" /></div>  
</div>  
</body>  
</html>



ဒီတစ္ခါ Front-End ကို refresh လုပ္လိုက္မယ္ ဆိုရင္ေတာ့ ဒီလိုေလးေျပာင္းလဲ သြားပါမယ္။


module position အသစ္မ်ားကို ထပ္ေပါင္းထည့္ျခင္း

module position အသစ္ေတြကို ေပါင္းထည့္ခ်င္ရင္ေရာ??  ရတာေပါ့ဗ်ာ :) ဆက္ၾကည့္လိုက္ရေအာင္
user1,user2,user3 ဆိုတဲ့ module position ေနာက္ထပ္ သုံးခုကို ထည့္ေပးမယ္ ဆိုရင္ေတာ့ index.php မွာ ဒီလိုေလး ေျပာင္းသြားပါမယ္။

<!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="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >  
<head>  
<jdoc:include type="head" />  
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/mytemplate_tut/css/template.css" type="text/css" />  
</head>  
 
<body>  
<div id="container">  
    <div id="header"> Header and stuff</div>  
    <div id="sidebar_left" class="float"><jdoc:include type="modules" name="left" /></div>  
    <div id="content" class="float">  
        <jdoc:include type="component" />  
    </div>  

    <div id="sidebar_right"class="float">Right sidebar</div>  
    <div class="clear"></div>
    <div id="user1" class="float"><jdoc:include type="modules" name="user1" /></div>
    <div id="user2" class="float"><jdoc:include type="modules" name="user2" /></div>
    <div id="user3" class="float"><jdoc:include type="modules" name="user3" /></div>
    
    <div id="footer" class="clear"><jdoc:include type="modules" name="footer" /></div>  
</div>  
</body>  
</html>



template.css မွာလည္း ဒီလိုေလး ျပင္လိုက္မယ္။

* {  
    padding: 0;  
    margin:0;  
    }  
ul {  
    list-style:none;  
    }
.float_right{
    float: right;
    
}
.float {  
    float: left;  
    }  
.clear {  
    clear: both;  
    }  
#container {  
    width:960px;  
    margin: auto;  
    }  
#header {  
    background-color:#659EC7;  
    height: 150px;  
    }  
#content {  
    width: 660px;  
    text-align: center;  
 
    }  
#sidebar_left {  
    text-align: center;  
    background-color:#95B9C7;  
    width: 150px;  
    }  
#sidebar_right {  
    background-color:#95B9C7;  
    width: 90px;  
    }  
#footer {  
    background-color:#98AFC7;  
    text-align:center;  
    }  
#user1{
    width: 320px;
    background-color: #78c7c7;  
}

#user2{
    width: 320px;
    background-color:#43BFC7;  
}

#user3{
    width: 320px;
    background-color:#77BFC7;  
}



templateDetails.xml ကိုလည္း module position အသစ္ user1, user2, user3 ကိုထပ္ျပီး ထည့္ေပးလိုက္မယ္။

   

<positions>
        
        <position>breadcrumb</position>
        <position>user1</position>
        <position>user2</position>
        <position>user3</position>
        <position>left</position>
        <position>right</position>
        <position>top</position>
        <position>footer</position>

    </positions>


အားလုံးျပီးရင္ေတာ့ Back-End ကေနျပီး user1, user2, user3 position ေတြအတြက္ module အသစ္သုံးခုကို ထည့္ျပီး Front End ကေနျပန္ၾကည့္ မယ္ဆိုရင္ေတာ့ ဒီလိုေျပာင္း သြားတာ ကို ေတြ႔ရမယ္။



ခုေလာက္ဆိုရင္ေတာ့ Joomla 1.5 based template တစ္ခုကို ဘယ္လိုတည္ေဆာက္မယ္ ဆိုတာ idea ရေလာက္ျပီး လို႕ထင္ပါတယ္။ ကြၽန္ေတာ္ idea အၾကမ္းေလးေပၚမွာကိုယ္ပိုင္ စိတ္ကူး ဥာဏ္ရွိ သေလာက္ ကြန္႕ျမဴး ႏိုင္ၾကပါေစဗ်ာ။

 

CKEditor in CodeIgniter

Written by Zack Sunday, 29 August 2010 22:32

ကြၽန္ေတာ္ ဒီ Post မွာ CKEditor ကို CodeIgniter မွာ ဘယ္လိုေပါင္း ထည့္မလဲ ဆိုတဲ့ Tutorial ကိုေရးမွာ ျဖစ္ပါတယ္။ ဒါေၾကာင့္ CI မွာ Helper ေတြ၊ Library ေတြကို ဘယ္လိုေပါင္းထည့္လို႕ ရတယ္ ဆိုတာကို ေရးထားတဲ့ ဒီ Post ကိုအရင္ ဖတ္ထားဖို႔ လိုပါတယ္။

CI ထဲကို ေပါင္းထည့္မယ့္ CKEditor အေၾကာင္းေလး ဗဟုသုတ အျဖစ္ နဲနဲၾကည္ လိုက္ရေအာင္။ CKEditor ဆိုတာကေတာ့ Web ေပၚမွာ user friendly ျဖစ္ေအာင္ လုပ္ေပးထားတဲ့ WYSIWYG editor အမ်ိဳးအစားပဲ ျဖစ္ပါတယ္။ WYSIWYG ကဆိုတာကေတာ့ What-You-See-Is-What-You-Get ကိုေျပာတာ ျဖစ္ပါတယ္။ ကြၽန္ေတာ္တို႔ Word ထဲမွာ Font Size, Font color, Font Style ေတြ၊ Number & Bullet ေတြ၊ Table Format ေတြကို အလြယ္တကူ လုပ္ႏိုင္ သလိုမ်ိဳး Web Page ေတြမွာ CKEditor ကိုသုံးျပီး လုပ္ႏိုင္ပါတယ္။ Web based ျဖစ္တာေၾကာင့္ Word ကိုေတာ့ Feature ေတြအကုန္ ယွဥ္လို႕ မရေပမယ့္ အသုံးဝင္တဲ့ Editor တစ္ခု ျဖစ္တာကေတာ့ အေသအခ်ာပါပဲ ခင္ဗ်ာ။ CKEditor ဆိုတာကေတာ့ 2003 ေလာက္ထဲက စတင္ခဲ့တဲ့ FCKEditor ရဲ႕ new generation အျဖစ္ 2009 မွာေျပာင္းလဲ ခဲ့တာျဖစ္ပါတယ္။

ဒါေၾကာင့္ ခုခ်ိန္မွာ Google မွာ FCKEditor လို႔ရွာရင္လဲ CKEditor ကိုပဲ ေတြ႔ရပါ လိမ့္မယ္။

အဲဒီ အသုံးဝင္တဲ့ကို CI ထဲကို ဘယ္လို ေပါင္းထည့္ မလဲ ဆိုတာ ဆက္ၾကည့္ ရေအာင္။

1) Download CKEditor

ဒီမွာ CKEditor ကို အရင္ Download လုပ္ဖို႔ လိုပါတယ္။

2) Create folder in CI for CKEditor

Download လုပ္ထားတဲ့ Folder ကိုဖြင့္ လိုက္လို႕  _samples ၊  _sources folder ေတြကိုေတြ႔ ခဲ့ရင္ေတာ့  အဲဒီ Folder ေတြ မရွိလည္း အလုပ္လုပ္တာမို႔ Delete လုပ္ျပစ္ရင္ ပိုေကာင္းပါတယ္။ မလုပ္လဲ ျပသနာ မရွိေသာ္လည္း server ေပၚအတင္အခ်ေတြမွာ အခ်ိန္ၾကာတာေတြ ျဖစ္ေစႏိုင္ပါတယ္။ ျပီးရင္ေတာ့ js folder ကို system folder နဲ႔ level တူေဆာက္ေပးျပီး အဲဒီေအာက္မွာ ckeditor ဆိုျပီး ေနာက္ folder တစ္ခုထပ္ေဆာက္ျပီး ခုနက _samples ၊  _sources folder ေတြ Delete လုပ္ျပီး က်န္ေနတဲ့ files ေတြ၊ folders ေတြ အားလုံးကို အဲဒီ ေအာက္မွာ copy ကူးျပီး ထည့္လိုက္ပါ။ Folder Structure ကိုၾကည့္မယ္ ဆိုရင္ေတာ့



3) Add CKEditor Helper in CI

ဒီအဆင့္မွာ helper file ေရးရမွာ ျဖစ္လို႕ application/helpers ေအာက္မွာ file အသစ္ တစ္ခု ေရးျပီးထည့္ ေပးရပါမယ္။ ဒီမွာ ေရးျပေနရင္ အရွည္ၾကီး ျဖစ္သြားမွာ စိုးတာေၾကာင့္ ဒီေနရာမွာ Download လုပ္ျပီး application/helpers ကိုထည့္ေပး လိုက္ပါ။ File name ကိုေတာ့ ckeditor_helper.php လို႔ေပး လိုက္ပါ။ အဲဒီ file ကို ဖြင့္ၾကည့္မယ္ ဆိုရင္ CKEditor ကိုသုံးရန္ လိုအပ္တဲ့ Function ေတြကို စုေရးထားတာ ေတြ႔ရပါမယ္။ Author ေရးထားတဲ့ အတိုင္းသုံးရတာ အဆင္ေျပေနတဲ့ အတြက္ျပင္ေနဖို႔ မလိုပါ။

4) Create Controller

ကြၽန္ေတာ္ထည့္လိုက္တဲ့ helper ကိုျပန္ေခၚဖို႔ Controller ကိုဆက္ လုပ္ပါမယ္။ ckeditor.php လို႔ နာမည္ေပးျပီး ဒီ code ေလးကိုထည့္ ေပးလိုက္ပါ။

<?php

class Ckeditor extends Controller {
   
    public $data     =     array();
   
    public function __construct() {
       
        parent::Controller();

        $this->load->helper('url'); //You should autoload this one ;)
        $this->load->helper('ckeditor');
       
        //Ckeditor's configuration
        $this->data['ckeditor'] = array(
       
            //ID of the textarea that will be replaced
            'id'     =>     'content',
            'path'    =>    'js/ckeditor',
       
            //Optionnal values
            'config' => array(
                'toolbar'     =>     "Full",     //Using the Full toolbar
                'width'     =>     "550px",    //Setting a custom width
                'height'     =>     '100px',    //Setting a custom height
                   
            ),
       
            //Replacing styles from the "Styles tool"
            'styles' => array(
           
                //Creating a new style named "style 1"
                'style 1' => array (
                    'name'         =>     'Blue Title',
                    'element'     =>     'h2',
                    'styles' => array(
                        'color'             =>     'Blue',
                        'font-weight'         =>     'bold'
                    )
                ),
               
                //Creating a new style named "style 2"
                'style 2' => array (
                    'name'         =>     'Red Title',
                    'element'     =>     'h2',
                    'styles' => array(
                        'color'             =>     'Red',
                        'font-weight'         =>     'bold',
                        'text-decoration'    =>     'underline'
                    )
                )               
            )
        );
       

    }
   
    public function index() {
       
        $this->load->view('ckeditor', $this->data);
       
    }
}



$this->load->helper('ckeditor'); ကေတာ့ ခုနလုပ္ထားတဲ့ helper file ကိုျပန္ေခၚတာ ပါတယ္။
CKEditor အတြက္လိုအပ္တဲ့ configuration, styles စတာေတြကို လိုခ်င္တဲ့ အတိုင္းေရးျပီး $this->data['ckeditor'] ဆိုျပီး array ထဲကို ထည့္လိုက္ပါတယ္။

id - CKEditor ရဲ႕ ID ပါ။
path - CKEditor Source ေတြကို Download ခ်ျပီး js folder ေအာက္ထားခဲ့တာ မွတ္မိမယ္ ထင္ပါတယ္။ အဲဒီ path ကိုေျပာတာပါ။
config - ဒီမွာေတာ့ toolbar, width, height စတာေတြကို လိုအပ္သလို parameter ေပးႏိုင္ပါတယ္။
style - CKEditor မွာ style ဆိုတဲ့ dropdown ေလးရွိေနျပီး ကိုယ့္ေရးထားျပီးသားကို select လုပ္ျပီး style dropdown ထဲကေန style တစ္ခုခုကိုေရြးတာနဲ႔ auto ေျပာင္းသြားပါမယ္။ အဲဒီ dropdown ထဲမွာေပၚမယ္ style ေတြအတြက္ ေရးထားျခင္း ျဖစ္ပါတယ္။

အားလုံးျပီးသြားေတာ့ view ကိုေခၚရင္း အဲဒီ data array ကိုထည့္ေပး လိုက္ပါတယ္။
$this->load->view('ckeditor', $this->data);

5) Create View

ေနာက္ဆုံး အဆင့္အေနနဲ႔ ckeditor.php ဆိုတဲ့ view ကိုေဆာက္ျပီး ဒီ code ေလးထည့္ေပး လိုက္ပါ။ သုံးသြားတဲ့ display_ckeditor function ကေန ckeditor_helper.php ထဲမွာ ေရးထားျပီးသားကို ေခၚလိုက္တာ ျဖစ္ပါတယ္။

ဒါကေတာ့ Googling လုပ္ရင္း ရွာေတြ႔တာ ေလးကို ျပန္ေရး ထားတာ ျဖစ္လို႕ တျခားနည္း တစ္ခုခုနဲ႔ CI ထဲေပါင္းထည့္တာ ရွိရင္လည္း comment မွာေရးထား ခဲ့ႏိုင္ပါတယ္။

 

Ref: http://kromack.com/developpement-php/codeigniter/ckeditor-helper-for-codeigniter/


 

Extend in CodeIgniter Framework

Written by Zack Saturday, 28 August 2010 22:23

ဒီ Post မွာ အဓိကထားျပီး ေရးမွာ ကေတာ့ CodeIgniter Framework ေပၚမွာ ရွိေနျပီးသား Library, Helper ေတြနဲ႔ မလုံေလာက္ ရင္ ျဖစ္ေစ၊ ကိုယ့္ Project Requirement အရ ေရးထည့္ဖို႔ လိုလာရင္ ျဖစ္ေစ Library, Helper အသစ္ေတြကို ဘယ္လိုထည့္ မလဲ ဆိုတာကို ျဖစ္ပါတယ္။ တစ္ နည္း အားျဖင့္ CI Framework ကိုဘယ္လို Extend လုပ္မလဲ ဆိုတာလဲ ျဖစ္ပါတယ္။ ကြၽန္ေတာ္ ေရးထားျပီးသား CI Post ေတြကို ျပန္ဖတ္ခ်င္ရင္ေတာ့

  1. CodeIgniter and MVC for Beginners
  2. Structure and Configuration of CodeIgniter
  3. CodeIgniter Database Library
  4. CodeIgniter Form Helper
  5. Simple Data Entry in CodeIgniter
  6. Pagination with CodeIgniter
  7. File upload in CodeIgniter


How to add own Helper

Okay အရင္ဆုံး helper တစ္ခုဘယ္လို ေပါင္းထည့္ မလဲ ဆိုတာေလး ၾကည့္ရေအာင္။ CI Structure မွာ application နဲ႔ system ရွိေနျပီး Built-In Library ေတြ၊ Helper ေတြအားလုံးက system ေအာက္မွာပဲ ရွိတယ္ဗ်ာ။ ကိုယ့္ အသစ္ထည့္ ခ်င္တာကို အဲဒီ Folder ေတြေအာက္မွာ သြားမထည့္ ရပါဘူး။ ဒါဆိုဘယ္မွာ ထည့္ရမလဲ ဆိုေတာ့ ... application folder ေအာက္မွာလည္း helpers, libraries folder ေတြရွိေနပါတယ္။ အဲဒီမွာ ထည့္ေပးရပါမယ္။

 

ကြၽန္ေတာ္ကေတာ့ helpers folder ေအာက္မွာ calculation_helper.php  ဆိုျပီး php file အသစ္တစ္ခု ေဆာက္လိုက္တယ္။ အဲဒီမွာ  မွတ္သား စရာ တစ္ခုကေတာ့ file name မွာ ေနာက္က _helper ဆိုတာပါရပါမယ္။ ဆိုလိုတာကဗ်ာ abc_hepler.php, xyz_helper.php စသည္ျဖင့္ ေရွ႕က ျဖစ္ခ်င္တာ ျဖစ္ျပီး ေနာက္က _helper.php နဲ႔ ဆုံးေပးရမယ္။ ျပီးေတာ့ ေရးေနၾကအတိုင္းပဲ function ေရးလို႕ ရပါတယ္။ ကြၽန္ေတာ္ကေတာ့ function add_value ကိုေရးထားလိုက္ပါတယ္။ 

<?php

function add_value($val1,$val2){
    return $val1 + $val2;
}

 

အဲဒီ Code ကို Controller ထဲက ေခၚ ၾကည့္ဖို႔ controller တစ္ခုကို ဆက္ျပီးေဆာက္မယ္။ 

<?php


class Test extends Controller{


    function calculate(){
        
      

     $this->load->helper('calculation');
        
      

     $val1 = 5; 
      

     $val2 = 3;
      

     echo "Result is " . add_value($val1,$val2);
  

    }
}

test.php ဆိုျပီး နာမည္ေပး လိုက္မယ္ဗ်ာ။ ဒါက ခုန ကြၽန္ေတာ္ေရးထားတဲ့ Helper calculation ကို loading လုပ္တာပါ။

$this->load->helper('calculation');


ကြၽန္ေတာ္ လုပ္ထားတာ calculation_helper ျဖစ္ေပမယ့္ ျပန္ေခၚေတာ့ _helper မပါေတာ့ပါဘူး။ တကယ္လို႕ ကိုယ့္က abc_helper.php ကိုလုပ္ထားခဲ့ မယ္ဆိုရင္ေတာ့ $this->load->helper('abc'); ေပါ့ဗ်ာ။ Browser ကေန ဒီလို Run လိုက္မယ္ ဆိုရင္ေတာ့

http://localhost:8888/ci_extend/index.php/test/calculate/

ႏွစ္ခု ေပါင္းထားတဲ့ result ကိုျမင္ရဖို႔ သုံးသြားတဲ့ add_value ဆိုတာကေတာ့ calculation_helper.php ထဲက ေခၚသြားတာ ျဖစ္ပါတယ္။
ဒါဆိုရင္ေတာ့ CI မွာ Helper အသစ္တစ္ခု ဘယ္လိုထည့္ မယ္ဆိုတာ Idea အၾကမ္းေတာ့ ရမယ္ ထင္ပါတယ္။
:)

 

How to add own Library

Library အသစ္တစ္ခု ဘယ္လိုေပါင္းထည့္ မလဲ ဆိုတာကို ဆက္ျပီး ၾကည့္လိုက္ရေအာင္။ application ေအာက္က libraries folder မွာ ကိုယ္ထည့္ ခ်င္တဲ့ library အသစ္တစ္ခုကို ထည့္ေပးရမယ္။ ကြၽန္ေတာ္က hello ဆိုတဲ့ Library ကိုထည့္ ဖို႔ ဒီလိုေလး ေရးလိုက္တယ္ဗ်ာ။ file name ကေတာ့ hello.php ေပါ့ဗ်ာ။

<?php
class hello{

function message(){
    echo "How are you?";
}
    
}
?>



အဲဒီမွာ class hello ဆိုရင္ ရပါျပီ။ controllers ေတြ model ေတြေရးတုန္းကလို extends လုပ္စရာမလိုပါ။ ကြၽန္ေတာ္ေရးထားတဲ့ message ကို controller ကေန သုံးၾကည့္ဖို႔  ခုနကြၽန္ေတာ္ ေရးထားျပီးသား controller file ျဖစ္တဲ့ test.php မွာ ဒီ code ေလးကို ထပ္ေပါင္းလိုက္ရေအာင္။

function hello_lib(){
    $this->load->library('hello');
    $this->hello->message();
}



ျပီးရင္ေတာ့ Browser ကေန ဒီလိုေလး run ၾကည့္မယ္ ဆိုရင္ေတာ့ 
http://localhost:8888/ci_extend/index.php/test/hello_lib/
"How are you?" ဆိုတဲ့ message ကိုျမင္ရမွာ ျဖစ္ပါတယ္။

How to use resource from existing Libraries

အဲဒီ ကိုယ္ထည့္လိုက္တဲ့ Library မွာ ရွိေနျပီးသား library ေတြထဲက value ေတြ function ေတြကို ျပန္သုံးခ်င္ရင္ေရာ ဘယ္လို လုပ္မလဲ ဆိုတာေလးကို ၾကည့္ရေအာင္။ ခုန ေရးထားတဲ့ Library ထဲမွာ ဒီ code ေလးကိုထည့္ ၾကည့္မယ္ေနာ္။  
 

function message(){
        echo "How are you?";
        $this->load->library->('config');
}



အရင္ အရင္ ေတြတုန္းက controllers, models ေတြထဲကေန အဲလို သုံးရင္ error မတတ္ေပမယ့္ ခုခ်ိန္မွာေတာ့ ဒီလို error တတ္မယ္ဗ်ာ။

ဘာလိုလဲ ဆိုေတာ့ $this က point လုပ္ေနတာက hello class ကိုျဖစ္ေနလိုပဲ ျဖစ္ပါတယ္။ ဒီေတာ့ super class object ကိုျပန္ယူေပးဖို႔  လိုပါတယ္။ အဲဒါေၾကာင့္ Library ကို ဒီလိုေလး ျပင္လိုက္မယ္။

<?php
class hello{
    
    var $CI;
    
    function hello(){
        $this->CI = & get_instance();
        
    }
    
    function message(){
        echo "How are you?";
        $this->CI->load->library('config');
        echo "My Languages is " . $this->CI->config->item('language');
        //$this->load->library->('config');
    }
}
?>



Class ထဲမွာ သုံးဖို႔ CI ဆိုတဲ့ variable ထဲကို $this->CI = & get_instance(); ဆိုျပီး super object ကို Reference(&) ယူလိုက္ပါတယ္။ အဲဒါေၾကာင့္ ဒီေနရာေတြမွာ $this->CI->load->library('config'); လို႕ျပန္သုံးတဲ့ အခါ error မတတ္ေတာ့ပဲ သုံးလို႕ ရသြား တာ ျဖစ္ပါတယ္။ ေနာက္ Post  မွာ CKEditor Library ကိုဘယ္လို ေပါင္းထည့္  မလဲ ဆိုတာ ေရးပါမယ္။ ဖတ္ျပီး နားမလည္တာ မွားေနတာ မရွင္းတာေတြ ရွိေနရင္လည္း comment ေပးေဆြးေႏြး ေပးဖို႔ ေတာင္းဆိုပါတယ္။ :)

 

Ref: http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-extending-the-framework/

 

Call phone from Gmail

Written by Zack Thursday, 26 August 2010 22:33

ဒီေန႕ 26th August မွာ Google ကေန Phone Call Feature ေလးကို ထည့္ေပးလိုက္တာ Gmail သုံးသူတိုင္း အားလုံး သိမွာပါ။
Gmail Blog မွာ သုံးသြားတဲ့ video ေလးကိုၾကိဳက္လို႕ ျပန္တင္ထားတာပါ။ 39 second ဆိုတဲ့ အခ်ိန္တိုေလးမွာ သူလိုခ်င္တဲ့ message ကိုရေအာင္ ေပးသြားတာကို သေဘာက်တာပါ။

ဒီမွာေတာ့ Google Voice: Calling Rates ေတြကို ၾကည့္ႏိုင္ပါတယ္။

https://www.google.com/voice/b/0/rates

 

Y2K38 in PHP

Written by Zack Tuesday, 24 August 2010 23:39

PHP မွာ ဒီ Code ေလးကို copy ကူးျပီး run ၾကည့္ရင္ ဘာေပၚမယ္ ထင္လဲ?

<?php  
$date = '2040-02-01';
$format = 'l d F Y H:i'; 
$mydate1 = strtotime($date); 
echo '<p>', date($format, $mydate1), '</p>';  
?>


Wednesday 1 February 2040 00:00 လို႔ေပၚမယ္ ထင္ပါသလား? ေရးရမွာ ပ်င္းရင္ေတာ့ ဒီမွာ run ၾကည့္လို႕ ရပါတယ္။ Result က ဒီလိုတဲ့ဗ်ာ။ Wednesday 31 December 1969 17:00

သူကို Y2K38 လို႔ေခၚျပီး 2038 ကေန စျပီး 1969/70 ကို ႏွစ္ေပါင္း ၇၀ ေလာက္နီးပါး  ေနာက္ ျပန္ေရာက္သြားတာ ကိုေတြ႔ရမယ္။ တကယ္လို႕မ်ား ကိုယ့္ application ထဲ membership plan ေတြကို ေရာင္းတဲ့ application ဆိုရင္ေတာ့ အဲဒီေန႕မွာ expire ျဖစ္မျဖစ္ ကိုဒီအတိုင္း စစ္ရင္မွား ပါေတာ့မယ္။

Date Time ကို ျပဖို႔ 32 Bits ကိုသုံးထားတဲ့ PHP နဲ႔ တျခားေသာ programming languages ေတြအားလုံးမွာ ဒီ bug ကိုေတြ႔ ရပါမယ္။ 32 bit မွာ Date Time ေတြကို 03:14:07 UTC on 19 January 2038 ေတြအထိပဲ ရွိေနျပီး အဲဒါေက်ာ္တာနဲ႔ left-most bit က negative ျဖစ္သြားျပီး 1969/70 ကိုျပန္ေရာက္ သြားတာ ျဖစ္ပါတယ္။

တကယ္လို႕ 64 bit OS ေပၚမွာ တင္ထားျပီး PHP ကလဲ 64 bit edition ဆိုရင္ေတာ့ ဒီ bug မေပၚႏိုင္ဘူးလို႕ ဆိုပါတယ္။ Coding ထဲက safe ျဖစ္ေအာင္လုပ္ ခ်င္ရင္ေတာ့ ဒီလိုေလး ေျပာင္းျပီး ေရးဖို႔လိုပါတယ္။

<?
$date = '2040-02-01';  
$format = 'l j F Y H:i';  
$mydate2 = new DateTime($date);  
echo '<p>', $mydate2->format($format), '</p>';
?>

 

Tools for Kid's Coding

Written by Zack Saturday, 21 August 2010 13:21

   ကြၽန္ေတာ္တို႔ေတြ Programming ကို   ေသခ်ာတတ္ေျမာက္ဖို႔ အေရးၾကီးတဲ့ အရာေတြက

   Thinking ေတြ၊ Concept  ေတြပဲ ျဖစ္ပါတယ္။   အဲဒါေတြကို  ေသခ်ာမသိပဲအာဂုံေဆာင္

   ေနမယ္ဆိုရင္ေတာ့တကယ္လက္ေတြ႔မွာ  အသုံးမဝင္တဲ့ အျပင္ ဒုကၡ ေရာက္သြားႏိုင္တဲ့   

   အေနအထား ရွိပါတယ္။ ဒါကလည္း ေလ့လာသင္ယူ သူေတြကိုပဲ အျပစ္ေျပာလို႕ မရ

   ဘူးလို႕ ထင္ပါတယ္။ ကြၽန္ေတာ္ Programming ကိုစလုပ္တဲ့ ၂၀၀၁/၀၂ ေလာက္တုန္း

   ကဆရာေျပာ လိုက္တဲ့ lopping ေတြ၊ IF-ELSE ေတြကို ေလ့က်င့္ဖို႔ resource ဆိုလို႕

စာရြက္ေလာက္သာ ကိုယ့္မွာ ရွိေနတာကိုး။ ဒါေၾကာင့္ လည္းစိတ္မဝင္စားသူေတြ အဖို႔ စာေမးပြဲေအာင္ေရး အတြက္ အာဂုံေဆာင္

အဆင့္မွာပဲ ဆုံးခန္းတိုင္ သြားတာေတြကို ကြၽန္ေတာ္ေတြ႔ဖူးပါတယ္။ Programming ရဲ႕ Thinking ေတြ Conpect ေတြ Mathematical

and Momputational ideas ေတြ ကို အလြယ္တကူရဖို႔ Tools ေတြ၊ Resource ေတြကို တကယ္ပဲ

မရွိေတာ့ဘူးလား??? ရွိတာေပါ့ဗ်ာ

 

ကြၽန္ေတာ္တို႔ေတြ အေၾကာင္း အမ်ိဳးမ်ိဳးေၾကာင့္ မသိခဲ့ မသုံးႏိုင္ခဲ့တာေတြ ကိုေျပာမေနေတာ့ပဲ ေနာက္မ်ိဳးဆက္ေတြ သိျပီး သုံးႏိုင္ေအာင္

လုပ္တာ ေပးၾကတာေပါ့ဗ်ာ။ အေနာက္ႏိုင္ငံေတြမွာ ၈ႏွစ္ အထက္ကေလးေတြကို Programming သင္ၾကားရာမွာ သုံးတဲ့ Tools ေတြ

အေၾကာင္းကို မိတ္ဆက္ေပးခ်င္ပါတယ္။ ကြၽန္ေတာ္ Tools ေတြအေၾကာင္းကို မစခင္  Microsoft's K-12 Computer Science

Academic Relations Manager ျဖစ္တဲ့ Alfred Thompson ရဲ႕ အဆိုေလးကို အရင္ဖတ္ၾကည့္ ေစခ်င္ပါတယ္။

We need to get students interested in computer science and that has to be done at an early age before they decide (incorrectly) that they can't do computer science or that it is dull and boring



1. Scratch

Scratch ဆိုတာကေတာ့ MIT Media Lab ကေန ၈ႏွစ္ အထက္ကေလးေတြအတြက္ ရည္ရြယ္ထားတဲ့ graphical programming

language ပဲျဖစ္ပါတယ္။ ၂၀၀၇ မွာ စျပီး release လုပ္ခဲ့တဲ့ scratch ဟာ ခုလက္ရွိခ်ိန္မွာ Projects ေပါင္း one million

ရွိေနျပီး ျဖစ္ပါတယ္။ Scratch ကိုသုံးျပီး ကိုယ္ပိုင္ animations, games, music, and art ေတြကို ဖန္တီးကာ web ေပၚမွာ

share ႏိုင္ပါျပီ။ Sharing project ေတြကို download လုပ္ျပီး remix လည္းလုပ္ႏိုင္ပါတယ္။ Scratch ကိုေလ့လာ ခ်င္တယ္ ဆိုရင္ေတာ့

ဒီမွာ Free Download လုပ္ႏိုင္ျပီး  Scratch Wiki ကို လည္းဖတ္ၾကည့္ ႏိုင္ပါတယ္။ ဒါကေတာ့ Scratch Developer ေတြ၊

သုံးေနတဲ့ ေက်ာင္းသား ကေလးငယ္ေတြရဲ႕ video ေလးပါ။

 


 

2. App Inventor

Google ကေနျပီး andriod သုံးစြဲသူေတြကို သာမန္ user  အဆင့္ကေန creator လုပ္ႏိုင္ေအာင္ ဖန္တီးေပးထားတဲ့ 

application  ေလးတစ္ခု ျဖစ္တယ္လို႕ Professor Harold Abelson ေျပာခဲ့တဲ့ အတိုင္း သာမန္ user ေတြ ဘယ္ေလာက္

လုပ္ေဆာင္ႏိုင္တယ္ ဆိုတာ ေအာက္က video ေလးကို ၾကည့္ရင္ သိပါလိမ့္မယ္။ Beta version သာရွိေနတဲ့ App Inventor ရဲ႕

Activity ေတြကို ဒီမွာ ဖတ္ႏိုင္ပါတယ္။




3. Alice

ေနာက္နာမည္ၾကီး တစ္ခုကေတာ့ Carnegie Mellon University က Product တစ္ခုျဖစ္တဲ့ Alice ဆိုတဲ့ open source 3D

programming ပဲျဖစ္ပါတယ္။  Alice မွာ Graphic ေတြကို  drag & drop ေတြနဲ႔ပဲ object-oriented၊ event-driven program ေတြကို

လြယ္ကူစြာ ဖန္တီးႏိုင္ ပါတယ္။ ကိုယ့္မွာ Thinking နဲ႔ Concept ရွိမယ္ဆိုရင္ အလြယ္တကူ အသုံးျပဳ ႏိုင္မွာ ျဖစ္ပါတယ္။ သူလည္းပဲ

Free ရႏိုင္ျပီး platform အေတာ္ေတာ္ မ်ားမ်ား ေျပာမယ္ဆိုရင္ (Win,Lunix,Mac) ေတြအားလုံးမွာ အလုပ္လုပ္ပါတယ္။ ဒါကေတာ့

Carnegie Mellon University က Alice's developer ေတြေျပာျပထားတဲ့ video ေလးတစ္ခုျဖစ္ပါတယ္။


4. Small Basic

Microsoft ရဲ႕ Small Basic ကေတာ့ "Programming is Fun" လို႔ဆိုထားျပီး သူရဲ႕ user friendly ျဖစ္တဲ့ development

environment ေတြအျပင္ မ်ားျပား ျပည့္စုံတဲ့ Library Files ေတြေၾကာင့္ ကိုယ္ပိုင္  game တစ္ခု၊ application တစ္ခုကို

ဖန္တီး ႏိုင္ပါတယ္။ ကိုယ္ဖန္တီးထားတဲ့ program ေလးကို သူငယ္ခ်င္းေတြကို share ခ်င္ရင္လည္း ကိုယ့္ Blog, Website မွာ

ရွိေနတာကို Silverlight player နဲ႔ ကစားႏိုင္ပါတယ္။ ဒါအျပင္ Small Basic ဟာ .net ရဲ႕ အေျခခံ concept ေတြစုစည္းထား

တာေၾကာင့္ ေနာက္ပိုင္း .net ကိုဆက္ျပီး ေလ့လာ ခ်င္သူေတြ အတြက္ ပိုသင့္ေတာ္ မယ္ထင္ပါတယ္။

 

5. Kodu

သူလည္းပဲ Microsoft ရဲ႕ Product တစ္ခု ျဖစ္ျပီး Xbox ေပၚမွာ run ႏိုင္မယ့္ games ေတြကို ဖန္တီး ႏိုင္မယ့္ programming

environment  တစ္ခု ျဖစ္ပါတယ္။ Kodu မွာ classical programming languages ေတြလို႔ လုပ္ေဆာင္ႏိုင္တဲ့ အျပင္ Icon based နဲ႔

program အလြယ္တကူ ေရးလို႕ ရေအာင္ လုပ္ေဆာင္ထား တာေၾကာင့္လည္း နာမည္ၾကီး ျဖစ္ႏိုင္ပါတယ္။ Game တစ္ခုဖန္တီးဖို႔

ဘယ္ေလာက္လြယ္တယ္ ဆိုတာ 2009 CES မွာ Microsoft ကျပသြားတဲ့ Video ေလးျဖစ္ပါတယ္။



 

6. Lego Mindstorms

ဒီတစ္ခါေတာ့ software application တစ္ခုမဟုတ္ပဲ programmable robotics တစ္ခုျဖစ္တဲ့ robot ေလးတစ္ခုျဖစ္ပါတယ္။

ဒါေလးကေတာ့ ကေလးငယ္ ေလးေတြအတြက္ ပိုျပီး အဆင္ေျပ သင့္ေတာ္ မယ္လို႕ ထင္ပါတယ္။



Computer Science ကေပးတဲ့ logic, critical thinking, problem solving ေတြဟာ ဘယ္ field မွာ မဆို apply ျပန္လုပ္ႏိုင္ျပီး

baseline တစ္ခု အေနနဲ႔ ရွိေနတာေၾကာင့္ ေနာက္မ်ိဳးဆက္ေတြကို ဒီလို Programming ကိုေလ့လာ သင္ယူဖို႔ လြယ္ကူေစမယ့္

Tools/Programming ေတြကို ေျပာျပၾကရ ေအာင္လာဗ်ာ။ MMTuts မွာလည္း ကိုသီဟေရးထားတဲ့ ဒီ Article ႏွစ္ခုကို ဆက္ျပီး

ဖတ္ေစခ်င္ပါတယ္။

  1. Programming သင္ဖို႔ရာ နည္းလမ္းသစ္မ်ားစြာ
  2. Do-It-Yourself (or) ေနာက္ထပ္လိႈင္းတစ္ခု


Ref: http://www.readwriteweb.com/archives/4_tools_for_teaching_kids_to_code.php


 

Page 1 of 30

«StartPrev12345678910NextEnd»

Login Form

Categories Table View

RSS Feed

JoomlaWatch Stats 1.2.9 by Matej Koval

Facebook Share

Share on facebook

mod_joomtouch

Version Iphone

Version Iphone by JoomTouch