Kowser
2 hand 2 leg 2 ear and 2 eyes... i am a man who is living to live...
2 hand 2 leg 2 ear and 2 eyes... i am a man who is living to live...
Sakif Shahriar: button.setOnClickListener(new View.OnClickListener)
Sakif Shahriar: {
Sakif Shahriar: //code
Sakif Shahriar: }
Sakif Shahriar: =))
Sakif Shahriar: what happened here?
Sakif Shahriar: explain regarding OOP
kowser: when button will be clicked
kowser: it will notify to listener
kowser: our listener will be able to listen
Sakif Shahriar: button class got “setOnclick” method
Sakif Shahriar: takes “onclick listenr” from view class as parameter
kowser: and than it will execute the //code
Sakif Shahriar: ![]()
Sakif Shahriar: is it so?
kowser: yes
Sakif Shahriar: ![]()
Sakif Shahriar: yey, I got it
kowser: now
kowser: u can have diff type of listener
kowser: and they will be notified with diff info
kowser: say, you asked ur friend to buy a book for u, and inform u when done
kowser: asked for song to other friend
kowser: or asked for food to another friend
kowser: surely they will give u response
kowser: when done
kowser: but those will be diff
kowser: right?
Sakif Shahriar: =))
Here is the 2nd part of 3 part series of Kohana tutorial. First part of this tutorial can be found here as Kohana Tutorial: For the beginners. Same as before it is going to be 10+/- steps.
Its tedious and repetitive task to create and manage all the view files with header, footer, menu… etc all the time. So it could be better, if we had a common template to handle this kind of stuffs. Kohana have Template Controller to rescue you.
We want that, our website will have common pattern with header, menu, css etc. We need to create a simple template file like as below.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Kohana Blog</title>
<!-- this is how, you you can add a css file -->
<?php echo HTML::style("public/css/template.css"); ?>
<!-- this is how, you you can add a javascript file -->
<?php echo HTML::script("public/js/jquery-1.6.4.js"); ?>
</head>
<body>
<div id="wrapper">
<!-- Header for the site -->
<div id="header"><h1>Kohana Blog</h1></div>
<!-- Menu for the site -->
<div id="navlist">
<ul>
<li><?php echo HTML::anchor("", "Home"); ?></li>
<li><?php echo HTML::anchor("article", "Articles"); ?></li>
<li><?php echo HTML::anchor("article/edit", "New Article"); ?></li>
</ul>
</div>
<!-- here we load all content -->
<div id="content">
<?php echo $content; ?>
</div>
<!-- no footer added -->
</div>
</body>
</html>
Now we need to say our controller that, from now on you are going to handle the template yourself. To do this we need to change our article controller. We can do it in following way.
// extends the Controller_Template
class Controller_Article extends Controller_Template {
public $template = 'template';
...
public function action_index() {
$articles = ORM::factory('article')->find_all(); // loads all article object from table
$view = new View('article/index'); // load 'article/index.php' view file
$view->set("articles", $articles); // set "articles" object to view
$this->template->set('content', $view); // renders a view as a response
}
...
}
It should be fun and easy to do this. Now hit the url: http://localhost/kohana-blog/index.php/article and see the magic. We can see a nice look of our Kohana Blog.
Read more »Some of my findings about Libya. Reference added.
Reference: http://en.wikipedia.org/wiki/Education_in_Libya (just take a look at the right side statistics column)
| Country | GDP (nominal) per capita (2010 est.) | World Rank | ||
|---|---|---|---|---|
| Comparision of GDP (nominal) per capita | ||||
| USA | $47,200 | 11 | ||
| Libya | 14,000 | 82 | ||
| Bangladesh | $1,700 | 196 | ||
https://www.cia.gov/library/publications/the-world-factbook/geos/us.html
https://www.cia.gov/library/publications/the-world-factbook/geos/ly.html
https://www.cia.gov/library/publications/the-world-factbook/geos/bg.html
According to 2004 U.S. government estimates, 82 percent of the total adult population (age 15 and older) is literate, or 92 percent of males and 72 percent of females.
http://en.wikipedia.org/wiki/Education_in_Libya
Live long Demo Crazy
যেই গফুর খেতে ভাত পায় না তার আবার কিডনি নিয়ে জমিদারী!!! কিডনি একটা বেচে দিলে কি হবে? আরেকটা তো আছে…
ট্রানজিট এর মানে গফুরের বুঝার কি দরকার? ট্রানজিট জিনিসটাও তো একই, তাই না? এত দিয়ে হবে কি? আছে তো অনেক, দাদাদের একটু দিয়ে দিলেই হল |
সমস্যা সেখানে না, সমস্যা হল যে দেশের মানুস তার নিজের অঙ্গ এর প্রয়োযন বুযতে পারেনা তাদের কাছে ট্রানজিট এর গুরুত্ত কতটুকু, ব্য়ক্ষা নিস্প্রয়োজন |
ট্রানজিট কেনো, পুরো দেশটাই যদি দিয়ে দেয়া হয়, গফুর দের ভাগ্য পরিবর্তনের নয় | কারণ গফুর দের ভাগ্য জমিদারের হাতে |
তিন বিঘা করিডর | যেখানে ৪০ বছর লাগলো, দিন রাত ২৪ ঘন্টা গফুরদের চলাচলের অনুমতি যোগার করতে সেখানে যদি আমরা ২.৫ বছরে দেশের মধ্যে দিয়ে রাস্তা দিতে নাইবা পারি তাহলে আমরা বন্ধু হলাম কিভাবে?
দাদারা ৪০ বছরে করিডর দিয়েছেন | ৪ বছরে ট্রানজিট (করিডর না কিন্তু) দিয়ে প্রমান করব দাদাদের প্রতি গফুরদের (জমিদারের ?) আনুগত্য |
গফুরের লজ্জা হওয়া উচিত, গফুরের কিডনি তো জমিদার নেয়নি, কিংবা তার শেষ জমিটুক…
শুধু গফুরের দেশের উপর দিয়ে জমিদারের বন্ধুর জন্যে একটা রাস্তা হবে | ওই নিমকহারাম গফুরের বুকের উপর দিয়েও নয় |
Kohana is the framework I liked best among other PHP framework. Its an easy one also
. To me it is organized, highly object oriented, having clear separation of model, view & controller. Autoloading of classes is nice feature here also. Here is the tutorial I prepared. In a simple and short…
Probably you have downloaded the zip file from here. Below are the steps one by one. So lets start…
Kohana::init(array( 'base_url' => '/kohana-blog', ));
By default URL format for koahna is like http://<base_url>/index.php/<controller>/<action>. So for an example http://localhost/kohana/index.php/article/new means it will be looking for article controller (Controller_Article) and execute new action (action_new()). If action part is empty, index action will be executed
.
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Welcome extends Controller {
public function action_index() {
$this->response->body('hello, world!');
}
} // End Welcome
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Welcome extends Controller {
public function action_index() {
$this>response->body('hello, world!');
}
public function action_another() {
$this->response->body('added another action...');
}
} // End Welcome
Now try this url: http://localhost/kohana-blog/index.php/welcome/another
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Article extends Controller {
public function action_index() {
$this->response->body("Kohana Blog");
}
}
Now try this url: http://localhost/kohana-blog/index.php/article/index
<?php defined('SYSPATH') or die('No direct script access.'); ?>
<h1>Kohana Blog Homepage</h1>
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Article extends Controller {
public function action_index() {
$view = new View('article/index'); // loads the 'article/index.php' file under 'application/view' folder
$this->response->body($view); // render the view as response
}
}
Now try this url again: http://localhost/kohana-blog/index.php/article/index
Read more »