Home > cakePHP, PHP > PHP – cakePHP understand

PHP – cakePHP understand

Target: Understanding its framework and basic view & controllers

1. controller codes:
shamun_controller.php

<?php
// /shamun/login or shamun/index
class ShamunController extends AppController {
// Still no idea
//var $name = “Shamun”;

// No database table to search
var $uses = null;

// goto view > /shamun/
function index(){
$this->layout = ‘nomenu’;
}

// goto view > /shamun/login
function login(){
$this->layout = ‘nomenu’;
//$this->render(‘login’,’nomenu’,’shamun’);
}

}
?>

2. views codes:

layouts >
default.ctp
… header….
<?php
echo $content_for_layout;
?>
,.. footer

nomenu.ctp
<?php
echo $content_for_layout;
?>

page >
home.ctp

shamun >

login.ctp
I am a login page: view (i will be overwrite on $content_for_layout).

index.ctp
<nothing…>

3. visit : http://localhost/cakephp/shamun
brings… nomenu.ctp with “shamun/index.ctp”

4. visit: http://localhost/cakephp/shamun/login

brings.. nomenu.ctp with “shamun/login.ctp”

Advertisements
Categories: cakePHP, PHP
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: