SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Downloaden Sie, um offline zu lesen
Views
Jill Gundersen
Views
 Presentation Layer


Display the desired output from the request to the user.

 Usually in HTML


Can also be…





XML
JSON
RSS
Files and Streaming Files

 CakePHP Template Files



Written in plain PHP
.ctp ending


CakePHP supports other templating languages such as Smarty or Twig
Parts of the View Layer
 View Layer Consists of 4 Parts


layouts




views




Displays a unique response based on the action being run

elements




The main layout for the website

Reusable code rendered inside of a view

helpers


Provides view logic and helps build code for forms, pagination, etc.
Layout
 Presentation Layer


Does not include the views

Layout

 Contents


Layout file contains the actual
<html>,<head>, and <body> tags.

 Wraps around your views
 Location


/app/View/Layouts/

 Default Layout



default.ctp
/app/View/Layouts/default.ctp

 Creating New Layout



home.ctp
/app/View/Layouts/home.ctp

View
Rendered View
 ‘content’ Block


Example




$this->fetch(‘content’);

Contains the rendered views



Layout

index.ctp
view.ctp

View
$this->fetch(‘content’);

 Location?


This ‘content’ block can be placed anywhere in the Layout


Typically in the main section of your layout
Page Title
 Individual Page Title



The layout <title> tag can be set on any page.
Using a specific a variable in the action of a controller or on the view
template itself

 Variable Name



title_for_layout
Example


$this->set(‘title_for_layout’, ‘Our List of Delicious Cakes’);
CSS and Images
 CSS and Images



Styles and images can be added to the site
Located:



/app/webroot/css – CSS Folder
/app/webroot/img – Image Folder

 Linking CSS


Example





$this->Html->css(‘nameOfStyleSheet’);
No need to add the .css

Called in the layout template or the view template.


The view template call has a couple more parameters and we will cover that later
in this module.

 Displaying images


Example





$this->Html->image(‘nameOfImage.jpg’)

Used in any view template or layout
This will be covered in more depth later in this module
Multiple Layouts
 Different Layouts


Sometimes you need different layouts for different occasions


Sign up form, promotional, blog template

 Layout Choice



Can be set in the controller or the view template file
Example



$this->layout = ‘promotional’;
$this->layout = ‘default’;
Views
 Display Specific Content




Specific content for a specific page
We created a few in our catalog site
Location





/app/Views/ControllerName/view_name.ctp

View names are based on the controller action
Override the default view by using


$this->render(‘view_name’);
Extending Views
 Extending Views


Common views can be extended for use with detailed views




Located in the app/Views directory inside the Common folder




Detailed views are the regular views associated with the controller actions
app/Views/Common/view.ctp

Example of Common View



Same header layout for all of the page views, the only difference is the title
Example





$this->fetch(‘content’) – mandatory for all common views
$this->fetch(‘title’);

Detailed View




Extend the common view
Assign the title
Example



$this->extend(‘/Common/view’);
$this->assign(‘title’, ‘New Title Name’);
Extending Views – Visual Representation

View

Common View

$this->extend(‘/Common/view’)

$this->fetch(‘title’)

$this->assign(‘title’, ‘New Title’)

$this->fetch(‘content’)

Layout
$this->fetch(‘content’)
Extending CSS
 Specific Page/View CSS


The layout contains a fetch call for CSS.





$this->fetch(‘css’);

Normally in a view template you would “assign” the css
Different Call



This changed in version 2.4
$this->Html->css(‘cssFile', null, array('inline' => false));
Elements
 Think Reusability


Bits of Code





Available on different pages
Different locations

Examples:


Sub Navigation, Quote Box, Ads

 Location



app/View/Elements/
Template file (.ctp - just like all other view templates)
Using Elements
 In Your View




Call the element method and pass as the parameter your element
view name
Example


echo $this->element(‘quote_box’);

 Passing Variables into an Element



A second parameter can be passed into the element method
Associated array





key = the name of the variable
value = variable content

Example



echo $this->element(‘quote_box’, array(‘quote’ => ‘CakePHP is awesome!’);
echo $quote;
Helpers
 What Are Helpers?





“Helpers are component-like classes for the presentation layer of [our]
application” – CakePHP Site
They help create “well-formed markup”
Basically they produce nuggets of code that we constantly use.

 Include in Controller




All helpers need to be included in the Controller.
Set the variable $helpers in either the current controller or the AppController
Example


public $helpers = array(‘Form’, ‘Html’)
Helpers
 Use



We have used some of these Helpers throughout our Catalog site.
CakePHP has a number of Helpers, here is a list of them with the parameter
value:











CacheHelper (Cache)
FormHelper (Form)
HtmlHelper (Html)
JsHelper (Js)
NumberHelper (Number)
Paginator – special scenario
RSS (Rss)
SessionHelper (Session)
TextHelper (Text)
TimeHelper (Time)
Helpers
 Use



We have used some of these Helpers throughout our Catalog site.
CakePHP has a number of Helpers, here is a list of them with the parameter
value:











CacheHelper (Cache)
FormHelper (Form)
HtmlHelper (Html)
JsHelper (Js)
NumberHelper (Number)
Paginator – special scenario
RSS (Rss)
SessionHelper (Session)
TextHelper (Text)
TimeHelper (Time)
HtmlHelper
 Basic Function of the HtmlHelper



The HtmlHelper generates code that is “well-formated” and used often.
Helps with tags we often forget the syntax to


For Example: Style sheets - We know it’s a link tag, but does the link tag take a
“href” for the source file or a “src”?

 Lots of Methods


The HtmlHelper has a lot of helpful methods, but we are only going to cover
the following:






css
image
script

We will cover the basics of each

 Link to HtmlHelpers


http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html
HtmlHelper - CSS
 Updated


Method has changed in version 2.4





This will not work with the current version of CakePHP we are working with.
If you have version 2.3 installed please refer to the segment on Views earlier in
this module.

Information below is for the 2.4 version.

 Takes One or Two Parameters


Focus only on the first parameter, second is optional

 First Paramenter


CSS file name or an array of CSS file names




Example





This is relative to the app/webroot/css folder
echo $this->Html->css(‘styleSheet’); // .css file extention not needed
echo $this->Html->css(array(‘menus’, ‘layout’)); // .css file extention not needed

Output



<link rel=“stylesheet” type=“text/css” href=“/css/menus.css” />
<link rel=“stylesheet” type=“text/css” href=“/css/layout.css” />
HtmlHelper - Image
 Parameters


First – string path to the image




This is relative to the app/webroot/img folder

Second – optional associated array of options (html attributes)

 Example


echo $this->Html->image(‘chocCake.jpg’, array(‘alt’ => ‘Chocolate Cake’);

 Output


<img src=“/img/chocCake.jpg” alt=“Chocolate Cake” />
HtmlHelper - Script
 Similar to the CSS Method
 Parameters


First – String to a single JS file, or an array of JS files.







This is relative to the app/webroot/js folder
Will also allow for directories outside webroot/js folder
Can also take a path to a remote URL

Second – optional associated array of options (html attributes)
We will only focus on the first parameter

 Example




echo $this->Html->script(“scripts”);
echo $this->Html->script(“/newJSDirectory/scripts”);
echo $this->Html->script(“http://www.somesites.com/jsFile.js”);


Notice you must include the extention

 Output


<script type=“text/javascript” src=“/js/scripts.js”></script>
FormHelper
 Basic Function of the FormHelper




The FormHelper generates the needed code for form creation
Creates forms quickly
Streamlines validation, re-population and layout.

 Lots of Methods


The FormHelper has a lot of methods. We will be covering the following:








create
end
hidden
password
input

We will cover the general basics of each of them

 Link to FormHelper


http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html
FormHelper - Create
 Parameters



First – optional string model name
Second – optional associated array of options

 Defaults


Form method defaults to ‘post’

 Example


General Add or Edit form with Model


echo $this->Form->create(“Items”);

 Output



<form id=“ItemAddForm” method=“post” action=“/items/add”>
If Edit form



<form id=“ItemEditForm” method=“post” action=“/items/edit/5”>
<input type=“hidden” name=“_method” value=“PUT” />
FormHelper - End
 Single Parameter Optional



String name for submit button or
Associated array of options

 Example



echo $this->Form->end();
echo $this->Form->end(“Add Item”);

 Output



</form>
<div class=“submit”>
<input type=“submit” value=“Add Item” />
</div>
</form>
FormHelper - Hidden
 Parameters



First - string field name
Second – optional associated array of options

 Example


echo $this->Form->hidden(“id”);

 Output


<input name=“data[Item][id]” value=“16” id=“ItemId” type=“hidden” />
FormHelper - Password
 Parameters



First - string field name
Second – optional associated array of options

 Example


echo $this->Form->password(“password”);

 Output


<input name=“data[User][password]” value=“” id=“UserPassword”
type=“password” />
FormHelper - Input
 Parameters



First – string field name
Second – optional associated array of options

 Basic Understanding


Output of an input method





div container
label tag
input tag
error element (if applicable)
FormHelper - Input
 Basic Understanding Cont’d




The input method determines what type of input you need based on the
field that is provided (first parameter).
Below is a list of associations based on column type

Column Type

Form Field

string (char, varchar, etc.)

text

boolean, tinyint(1)

checkbox

text

textarea

text (field name of password, passwd, psword)

password

text (field name of email)

email

text (field name of tel, telephone, phone)

tel

date

day, month, and year selects

datetime

day, month, year, hour, minute, and
meridian selects

time

hour, minute, and meridian selects
FormHelper - Input
 Input Options




Optional
Associated array, key/value pairs
Below is a list of a few different types of options available. The full list can be
found here


http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#options

 Options List


Type – Force the type of input to be used




Label – provide personal text for the label tag




Example – ‘default’ => ‘Chocolate Cake’

Selected – set a selected option based on the value provided




Example – ‘label’ => ‘First Name’

Default – set the default value of the field




Example - ‘type’ => ‘email’

Example – ‘selected’ => ‘3’

Rows, Cols – set the rows and columns of a text area


Example – ‘rows’ => ‘5’, ‘cols’ => ‘10’
FormHelper - Input
 Example – Add an Item Form

 Example – Edit an Item Form
Summary
 Four Parts of the View





Layout
Views
Elements
Helpers

 Layout
 Views


Extending Views

 Elements


Reusable code

 Helpers



Code shortcuts
HtmlHelper, FormHelper

Weitere ähnliche Inhalte

Was ist angesagt?

Build website in_django
Build website in_django Build website in_django
Build website in_django swee meng ng
 
CakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldCakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldGraham Weldon
 
LvivPy - Flask in details
LvivPy - Flask in detailsLvivPy - Flask in details
LvivPy - Flask in detailsMax Klymyshyn
 
Web development with django - Basics Presentation
Web development with django - Basics PresentationWeb development with django - Basics Presentation
Web development with django - Basics PresentationShrinath Shenoy
 
Basic Crud In Django
Basic Crud In DjangoBasic Crud In Django
Basic Crud In Djangomcantelon
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for BeginnersJason Davies
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Edureka!
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using DjangoNathan Eror
 
Introduction to django
Introduction to djangoIntroduction to django
Introduction to djangoIlian Iliev
 
The Django Web Application Framework
The Django Web Application FrameworkThe Django Web Application Framework
The Django Web Application FrameworkSimon Willison
 
RESTful Web Development with CakePHP
RESTful Web Development with CakePHPRESTful Web Development with CakePHP
RESTful Web Development with CakePHPAndru Weir
 
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial之宇 趙
 
PloneNG: What's new in Plone 4.2, 4.3, and beyond
PloneNG: What's new in Plone 4.2, 4.3, and beyondPloneNG: What's new in Plone 4.2, 4.3, and beyond
PloneNG: What's new in Plone 4.2, 4.3, and beyondDavid Glick
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flaskjuzten
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture IntroductionHaiqi Chen
 
Django app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh AgarwalDjango app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh Agarwalratneshsinghparihar
 

Was ist angesagt? (20)

Build website in_django
Build website in_django Build website in_django
Build website in_django
 
CakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldCakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your world
 
LvivPy - Flask in details
LvivPy - Flask in detailsLvivPy - Flask in details
LvivPy - Flask in details
 
Web development with django - Basics Presentation
Web development with django - Basics PresentationWeb development with django - Basics Presentation
Web development with django - Basics Presentation
 
Basic Crud In Django
Basic Crud In DjangoBasic Crud In Django
Basic Crud In Django
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for Beginners
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using Django
 
Introduction to django
Introduction to djangoIntroduction to django
Introduction to django
 
The Django Web Application Framework
The Django Web Application FrameworkThe Django Web Application Framework
The Django Web Application Framework
 
Flask
FlaskFlask
Flask
 
RESTful Web Development with CakePHP
RESTful Web Development with CakePHPRESTful Web Development with CakePHP
RESTful Web Development with CakePHP
 
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial
 
PloneNG: What's new in Plone 4.2, 4.3, and beyond
PloneNG: What's new in Plone 4.2, 4.3, and beyondPloneNG: What's new in Plone 4.2, 4.3, and beyond
PloneNG: What's new in Plone 4.2, 4.3, and beyond
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
 
Cakephp
CakephpCakephp
Cakephp
 
Zend framework
Zend frameworkZend framework
Zend framework
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
 
Django
DjangoDjango
Django
 
Django app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh AgarwalDjango app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh Agarwal
 

Ähnlich wie 6 introduction-php-mvc-cakephp-m6-views-slides

Drupal8 render pipeline
Drupal8 render pipelineDrupal8 render pipeline
Drupal8 render pipelineMahesh Salaria
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practicesmarkparolisi
 
CustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputsCustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputsSuite Solutions
 
Practical HTML5: Using It Today
Practical HTML5: Using It TodayPractical HTML5: Using It Today
Practical HTML5: Using It TodayDoris Chen
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsAlessandro Molina
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 
Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101Ted Kulp
 
Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)christopherfross
 
Templates, partials and layouts
Templates, partials and layoutsTemplates, partials and layouts
Templates, partials and layoutsKadiv Vech
 
Zend Framework Quick Start Walkthrough
Zend Framework Quick Start WalkthroughZend Framework Quick Start Walkthrough
Zend Framework Quick Start WalkthroughBradley Holt
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentationipolevoy
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...LinnAlexandra
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolGordon Forsythe
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep DiveGabriel Walt
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Phpfunkatron
 
GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1Heather Rock
 

Ähnlich wie 6 introduction-php-mvc-cakephp-m6-views-slides (20)

Actionview
ActionviewActionview
Actionview
 
Drupal8 render pipeline
Drupal8 render pipelineDrupal8 render pipeline
Drupal8 render pipeline
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
 
CustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputsCustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputs
 
Practical HTML5: Using It Today
Practical HTML5: Using It TodayPractical HTML5: Using It Today
Practical HTML5: Using It Today
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101
 
Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)
 
Templates, partials and layouts
Templates, partials and layoutsTemplates, partials and layouts
Templates, partials and layouts
 
JavaServer Pages
JavaServer PagesJavaServer Pages
JavaServer Pages
 
HTML/HTML5
HTML/HTML5HTML/HTML5
HTML/HTML5
 
Zend Framework Quick Start Walkthrough
Zend Framework Quick Start WalkthroughZend Framework Quick Start Walkthrough
Zend Framework Quick Start Walkthrough
 
Best practices tekx
Best practices tekxBest practices tekx
Best practices tekx
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep Dive
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1
 

Mehr von MasterCode.vn

Pd ftai lieu-tieng-anh-cho-nguoi-moi-bat-dau-mastercode.vn
Pd ftai lieu-tieng-anh-cho-nguoi-moi-bat-dau-mastercode.vnPd ftai lieu-tieng-anh-cho-nguoi-moi-bat-dau-mastercode.vn
Pd ftai lieu-tieng-anh-cho-nguoi-moi-bat-dau-mastercode.vnMasterCode.vn
 
Why apps-succeed-wpr-mastercode.vn
Why apps-succeed-wpr-mastercode.vnWhy apps-succeed-wpr-mastercode.vn
Why apps-succeed-wpr-mastercode.vnMasterCode.vn
 
Dzone performancemonitoring2016-mastercode.vn
Dzone performancemonitoring2016-mastercode.vnDzone performancemonitoring2016-mastercode.vn
Dzone performancemonitoring2016-mastercode.vnMasterCode.vn
 
Google công bố thông tin lịch xu hướng ngành 2017 mastercode.vn
Google công bố thông tin lịch xu hướng ngành 2017 mastercode.vnGoogle công bố thông tin lịch xu hướng ngành 2017 mastercode.vn
Google công bố thông tin lịch xu hướng ngành 2017 mastercode.vnMasterCode.vn
 
Nghiên cứu về khách hàng mastercode.vn
Nghiên cứu về khách hàng mastercode.vnNghiên cứu về khách hàng mastercode.vn
Nghiên cứu về khách hàng mastercode.vnMasterCode.vn
 
Lập trình sáng tạo creative computing textbook mastercode.vn
Lập trình sáng tạo creative computing textbook mastercode.vnLập trình sáng tạo creative computing textbook mastercode.vn
Lập trình sáng tạo creative computing textbook mastercode.vnMasterCode.vn
 
Pd fbuoi7 8--tongquanseo-mastercode.vn
Pd fbuoi7 8--tongquanseo-mastercode.vnPd fbuoi7 8--tongquanseo-mastercode.vn
Pd fbuoi7 8--tongquanseo-mastercode.vnMasterCode.vn
 
Pd fbuoi5 6-ảnh hưởng của social media tới kết quả seo-mastercode.vn
Pd fbuoi5 6-ảnh hưởng của social media tới kết quả seo-mastercode.vnPd fbuoi5 6-ảnh hưởng của social media tới kết quả seo-mastercode.vn
Pd fbuoi5 6-ảnh hưởng của social media tới kết quả seo-mastercode.vnMasterCode.vn
 
Pdf buoi3 4-link-building-tran-ngoc-chinh-mastercode.vn
Pdf buoi3 4-link-building-tran-ngoc-chinh-mastercode.vnPdf buoi3 4-link-building-tran-ngoc-chinh-mastercode.vn
Pdf buoi3 4-link-building-tran-ngoc-chinh-mastercode.vnMasterCode.vn
 
Pd fbuoi3 4-kỹ thuật xây dựng back link-mastercode.vn
Pd fbuoi3 4-kỹ thuật xây dựng back link-mastercode.vnPd fbuoi3 4-kỹ thuật xây dựng back link-mastercode.vn
Pd fbuoi3 4-kỹ thuật xây dựng back link-mastercode.vnMasterCode.vn
 
Pd fbuoi2 onpage – tối ưu hóa trang web-mastercode.vn
Pd fbuoi2 onpage – tối ưu hóa trang web-mastercode.vnPd fbuoi2 onpage – tối ưu hóa trang web-mastercode.vn
Pd fbuoi2 onpage – tối ưu hóa trang web-mastercode.vnMasterCode.vn
 
Pd fbuoi1 giới thiệu seo tools cơ bản-seo manager + seo guy-mastercode.vn
Pd fbuoi1 giới thiệu seo tools cơ bản-seo manager + seo guy-mastercode.vnPd fbuoi1 giới thiệu seo tools cơ bản-seo manager + seo guy-mastercode.vn
Pd fbuoi1 giới thiệu seo tools cơ bản-seo manager + seo guy-mastercode.vnMasterCode.vn
 
Pdf buoi1 2-on-page-tran-ngoc-chinh-mastercode.vn
Pdf buoi1 2-on-page-tran-ngoc-chinh-mastercode.vnPdf buoi1 2-on-page-tran-ngoc-chinh-mastercode.vn
Pdf buoi1 2-on-page-tran-ngoc-chinh-mastercode.vnMasterCode.vn
 
Pdfbài 7 máy tính xác tay và máy in bảo trì sự cố máy tính-mastercode.vn
Pdfbài 7 máy tính xác tay và máy in   bảo trì sự cố máy tính-mastercode.vnPdfbài 7 máy tính xác tay và máy in   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 7 máy tính xác tay và máy in bảo trì sự cố máy tính-mastercode.vnMasterCode.vn
 
Pdfbài 6 bảo trì máy tính bảo trì sự cố máy tính-mastercode.vn
Pdfbài 6 bảo trì máy tính   bảo trì sự cố máy tính-mastercode.vnPdfbài 6 bảo trì máy tính   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 6 bảo trì máy tính bảo trì sự cố máy tính-mastercode.vnMasterCode.vn
 
Pdfbài 5 bảo trì và tối ưu windows bảo trì sự cố máy tính-mastercode.vn
Pdfbài 5 bảo trì và tối ưu windows   bảo trì sự cố máy tính-mastercode.vnPdfbài 5 bảo trì và tối ưu windows   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 5 bảo trì và tối ưu windows bảo trì sự cố máy tính-mastercode.vnMasterCode.vn
 
Pdfbài 4 ổ cứng hard drive bảo trì sự cố máy tính-mastercode.vn
Pdfbài 4 ổ cứng hard drive   bảo trì sự cố máy tính-mastercode.vnPdfbài 4 ổ cứng hard drive   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 4 ổ cứng hard drive bảo trì sự cố máy tính-mastercode.vnMasterCode.vn
 
Pdfbài 3 cpu và ram bảo trì sự cố máy tính-mastercode.vn
Pdfbài 3 cpu và ram   bảo trì sự cố máy tính-mastercode.vnPdfbài 3 cpu và ram   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 3 cpu và ram bảo trì sự cố máy tính-mastercode.vnMasterCode.vn
 
Pdfbài 1 giới thiệu chung về phần cứng bảo trì sự cố máy tính-mastercode.vn
Pdfbài 1 giới thiệu chung về phần cứng   bảo trì sự cố máy tính-mastercode.vnPdfbài 1 giới thiệu chung về phần cứng   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 1 giới thiệu chung về phần cứng bảo trì sự cố máy tính-mastercode.vnMasterCode.vn
 
Pdfbài 2 bo mạch chủ (main) bảo trì sự cố máy tính-mastercode.vn
Pdfbài 2 bo mạch chủ (main)   bảo trì sự cố máy tính-mastercode.vnPdfbài 2 bo mạch chủ (main)   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 2 bo mạch chủ (main) bảo trì sự cố máy tính-mastercode.vnMasterCode.vn
 

Mehr von MasterCode.vn (20)

Pd ftai lieu-tieng-anh-cho-nguoi-moi-bat-dau-mastercode.vn
Pd ftai lieu-tieng-anh-cho-nguoi-moi-bat-dau-mastercode.vnPd ftai lieu-tieng-anh-cho-nguoi-moi-bat-dau-mastercode.vn
Pd ftai lieu-tieng-anh-cho-nguoi-moi-bat-dau-mastercode.vn
 
Why apps-succeed-wpr-mastercode.vn
Why apps-succeed-wpr-mastercode.vnWhy apps-succeed-wpr-mastercode.vn
Why apps-succeed-wpr-mastercode.vn
 
Dzone performancemonitoring2016-mastercode.vn
Dzone performancemonitoring2016-mastercode.vnDzone performancemonitoring2016-mastercode.vn
Dzone performancemonitoring2016-mastercode.vn
 
Google công bố thông tin lịch xu hướng ngành 2017 mastercode.vn
Google công bố thông tin lịch xu hướng ngành 2017 mastercode.vnGoogle công bố thông tin lịch xu hướng ngành 2017 mastercode.vn
Google công bố thông tin lịch xu hướng ngành 2017 mastercode.vn
 
Nghiên cứu về khách hàng mastercode.vn
Nghiên cứu về khách hàng mastercode.vnNghiên cứu về khách hàng mastercode.vn
Nghiên cứu về khách hàng mastercode.vn
 
Lập trình sáng tạo creative computing textbook mastercode.vn
Lập trình sáng tạo creative computing textbook mastercode.vnLập trình sáng tạo creative computing textbook mastercode.vn
Lập trình sáng tạo creative computing textbook mastercode.vn
 
Pd fbuoi7 8--tongquanseo-mastercode.vn
Pd fbuoi7 8--tongquanseo-mastercode.vnPd fbuoi7 8--tongquanseo-mastercode.vn
Pd fbuoi7 8--tongquanseo-mastercode.vn
 
Pd fbuoi5 6-ảnh hưởng của social media tới kết quả seo-mastercode.vn
Pd fbuoi5 6-ảnh hưởng của social media tới kết quả seo-mastercode.vnPd fbuoi5 6-ảnh hưởng của social media tới kết quả seo-mastercode.vn
Pd fbuoi5 6-ảnh hưởng của social media tới kết quả seo-mastercode.vn
 
Pdf buoi3 4-link-building-tran-ngoc-chinh-mastercode.vn
Pdf buoi3 4-link-building-tran-ngoc-chinh-mastercode.vnPdf buoi3 4-link-building-tran-ngoc-chinh-mastercode.vn
Pdf buoi3 4-link-building-tran-ngoc-chinh-mastercode.vn
 
Pd fbuoi3 4-kỹ thuật xây dựng back link-mastercode.vn
Pd fbuoi3 4-kỹ thuật xây dựng back link-mastercode.vnPd fbuoi3 4-kỹ thuật xây dựng back link-mastercode.vn
Pd fbuoi3 4-kỹ thuật xây dựng back link-mastercode.vn
 
Pd fbuoi2 onpage – tối ưu hóa trang web-mastercode.vn
Pd fbuoi2 onpage – tối ưu hóa trang web-mastercode.vnPd fbuoi2 onpage – tối ưu hóa trang web-mastercode.vn
Pd fbuoi2 onpage – tối ưu hóa trang web-mastercode.vn
 
Pd fbuoi1 giới thiệu seo tools cơ bản-seo manager + seo guy-mastercode.vn
Pd fbuoi1 giới thiệu seo tools cơ bản-seo manager + seo guy-mastercode.vnPd fbuoi1 giới thiệu seo tools cơ bản-seo manager + seo guy-mastercode.vn
Pd fbuoi1 giới thiệu seo tools cơ bản-seo manager + seo guy-mastercode.vn
 
Pdf buoi1 2-on-page-tran-ngoc-chinh-mastercode.vn
Pdf buoi1 2-on-page-tran-ngoc-chinh-mastercode.vnPdf buoi1 2-on-page-tran-ngoc-chinh-mastercode.vn
Pdf buoi1 2-on-page-tran-ngoc-chinh-mastercode.vn
 
Pdfbài 7 máy tính xác tay và máy in bảo trì sự cố máy tính-mastercode.vn
Pdfbài 7 máy tính xác tay và máy in   bảo trì sự cố máy tính-mastercode.vnPdfbài 7 máy tính xác tay và máy in   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 7 máy tính xác tay và máy in bảo trì sự cố máy tính-mastercode.vn
 
Pdfbài 6 bảo trì máy tính bảo trì sự cố máy tính-mastercode.vn
Pdfbài 6 bảo trì máy tính   bảo trì sự cố máy tính-mastercode.vnPdfbài 6 bảo trì máy tính   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 6 bảo trì máy tính bảo trì sự cố máy tính-mastercode.vn
 
Pdfbài 5 bảo trì và tối ưu windows bảo trì sự cố máy tính-mastercode.vn
Pdfbài 5 bảo trì và tối ưu windows   bảo trì sự cố máy tính-mastercode.vnPdfbài 5 bảo trì và tối ưu windows   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 5 bảo trì và tối ưu windows bảo trì sự cố máy tính-mastercode.vn
 
Pdfbài 4 ổ cứng hard drive bảo trì sự cố máy tính-mastercode.vn
Pdfbài 4 ổ cứng hard drive   bảo trì sự cố máy tính-mastercode.vnPdfbài 4 ổ cứng hard drive   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 4 ổ cứng hard drive bảo trì sự cố máy tính-mastercode.vn
 
Pdfbài 3 cpu và ram bảo trì sự cố máy tính-mastercode.vn
Pdfbài 3 cpu và ram   bảo trì sự cố máy tính-mastercode.vnPdfbài 3 cpu và ram   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 3 cpu và ram bảo trì sự cố máy tính-mastercode.vn
 
Pdfbài 1 giới thiệu chung về phần cứng bảo trì sự cố máy tính-mastercode.vn
Pdfbài 1 giới thiệu chung về phần cứng   bảo trì sự cố máy tính-mastercode.vnPdfbài 1 giới thiệu chung về phần cứng   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 1 giới thiệu chung về phần cứng bảo trì sự cố máy tính-mastercode.vn
 
Pdfbài 2 bo mạch chủ (main) bảo trì sự cố máy tính-mastercode.vn
Pdfbài 2 bo mạch chủ (main)   bảo trì sự cố máy tính-mastercode.vnPdfbài 2 bo mạch chủ (main)   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 2 bo mạch chủ (main) bảo trì sự cố máy tính-mastercode.vn
 

Kürzlich hochgeladen

INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxDhatriParmar
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptxmary850239
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsPooky Knightsmith
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptxDhatriParmar
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17Celine George
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvRicaMaeCastro1
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 

Kürzlich hochgeladen (20)

INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young minds
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 

6 introduction-php-mvc-cakephp-m6-views-slides

  • 2. Views  Presentation Layer  Display the desired output from the request to the user.  Usually in HTML  Can also be…     XML JSON RSS Files and Streaming Files  CakePHP Template Files   Written in plain PHP .ctp ending  CakePHP supports other templating languages such as Smarty or Twig
  • 3. Parts of the View Layer  View Layer Consists of 4 Parts  layouts   views   Displays a unique response based on the action being run elements   The main layout for the website Reusable code rendered inside of a view helpers  Provides view logic and helps build code for forms, pagination, etc.
  • 4. Layout  Presentation Layer  Does not include the views Layout  Contents  Layout file contains the actual <html>,<head>, and <body> tags.  Wraps around your views  Location  /app/View/Layouts/  Default Layout   default.ctp /app/View/Layouts/default.ctp  Creating New Layout   home.ctp /app/View/Layouts/home.ctp View
  • 5. Rendered View  ‘content’ Block  Example   $this->fetch(‘content’); Contains the rendered views   Layout index.ctp view.ctp View $this->fetch(‘content’);  Location?  This ‘content’ block can be placed anywhere in the Layout  Typically in the main section of your layout
  • 6. Page Title  Individual Page Title   The layout <title> tag can be set on any page. Using a specific a variable in the action of a controller or on the view template itself  Variable Name   title_for_layout Example  $this->set(‘title_for_layout’, ‘Our List of Delicious Cakes’);
  • 7. CSS and Images  CSS and Images   Styles and images can be added to the site Located:   /app/webroot/css – CSS Folder /app/webroot/img – Image Folder  Linking CSS  Example    $this->Html->css(‘nameOfStyleSheet’); No need to add the .css Called in the layout template or the view template.  The view template call has a couple more parameters and we will cover that later in this module.  Displaying images  Example    $this->Html->image(‘nameOfImage.jpg’) Used in any view template or layout This will be covered in more depth later in this module
  • 8. Multiple Layouts  Different Layouts  Sometimes you need different layouts for different occasions  Sign up form, promotional, blog template  Layout Choice   Can be set in the controller or the view template file Example   $this->layout = ‘promotional’; $this->layout = ‘default’;
  • 9. Views  Display Specific Content    Specific content for a specific page We created a few in our catalog site Location    /app/Views/ControllerName/view_name.ctp View names are based on the controller action Override the default view by using  $this->render(‘view_name’);
  • 10. Extending Views  Extending Views  Common views can be extended for use with detailed views   Located in the app/Views directory inside the Common folder   Detailed views are the regular views associated with the controller actions app/Views/Common/view.ctp Example of Common View   Same header layout for all of the page views, the only difference is the title Example    $this->fetch(‘content’) – mandatory for all common views $this->fetch(‘title’); Detailed View    Extend the common view Assign the title Example   $this->extend(‘/Common/view’); $this->assign(‘title’, ‘New Title Name’);
  • 11. Extending Views – Visual Representation View Common View $this->extend(‘/Common/view’) $this->fetch(‘title’) $this->assign(‘title’, ‘New Title’) $this->fetch(‘content’) Layout $this->fetch(‘content’)
  • 12. Extending CSS  Specific Page/View CSS  The layout contains a fetch call for CSS.    $this->fetch(‘css’); Normally in a view template you would “assign” the css Different Call   This changed in version 2.4 $this->Html->css(‘cssFile', null, array('inline' => false));
  • 13. Elements  Think Reusability  Bits of Code    Available on different pages Different locations Examples:  Sub Navigation, Quote Box, Ads  Location   app/View/Elements/ Template file (.ctp - just like all other view templates)
  • 14. Using Elements  In Your View   Call the element method and pass as the parameter your element view name Example  echo $this->element(‘quote_box’);  Passing Variables into an Element   A second parameter can be passed into the element method Associated array    key = the name of the variable value = variable content Example   echo $this->element(‘quote_box’, array(‘quote’ => ‘CakePHP is awesome!’); echo $quote;
  • 15. Helpers  What Are Helpers?    “Helpers are component-like classes for the presentation layer of [our] application” – CakePHP Site They help create “well-formed markup” Basically they produce nuggets of code that we constantly use.  Include in Controller    All helpers need to be included in the Controller. Set the variable $helpers in either the current controller or the AppController Example  public $helpers = array(‘Form’, ‘Html’)
  • 16. Helpers  Use   We have used some of these Helpers throughout our Catalog site. CakePHP has a number of Helpers, here is a list of them with the parameter value:           CacheHelper (Cache) FormHelper (Form) HtmlHelper (Html) JsHelper (Js) NumberHelper (Number) Paginator – special scenario RSS (Rss) SessionHelper (Session) TextHelper (Text) TimeHelper (Time)
  • 17. Helpers  Use   We have used some of these Helpers throughout our Catalog site. CakePHP has a number of Helpers, here is a list of them with the parameter value:           CacheHelper (Cache) FormHelper (Form) HtmlHelper (Html) JsHelper (Js) NumberHelper (Number) Paginator – special scenario RSS (Rss) SessionHelper (Session) TextHelper (Text) TimeHelper (Time)
  • 18. HtmlHelper  Basic Function of the HtmlHelper   The HtmlHelper generates code that is “well-formated” and used often. Helps with tags we often forget the syntax to  For Example: Style sheets - We know it’s a link tag, but does the link tag take a “href” for the source file or a “src”?  Lots of Methods  The HtmlHelper has a lot of helpful methods, but we are only going to cover the following:     css image script We will cover the basics of each  Link to HtmlHelpers  http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html
  • 19. HtmlHelper - CSS  Updated  Method has changed in version 2.4    This will not work with the current version of CakePHP we are working with. If you have version 2.3 installed please refer to the segment on Views earlier in this module. Information below is for the 2.4 version.  Takes One or Two Parameters  Focus only on the first parameter, second is optional  First Paramenter  CSS file name or an array of CSS file names   Example    This is relative to the app/webroot/css folder echo $this->Html->css(‘styleSheet’); // .css file extention not needed echo $this->Html->css(array(‘menus’, ‘layout’)); // .css file extention not needed Output   <link rel=“stylesheet” type=“text/css” href=“/css/menus.css” /> <link rel=“stylesheet” type=“text/css” href=“/css/layout.css” />
  • 20. HtmlHelper - Image  Parameters  First – string path to the image   This is relative to the app/webroot/img folder Second – optional associated array of options (html attributes)  Example  echo $this->Html->image(‘chocCake.jpg’, array(‘alt’ => ‘Chocolate Cake’);  Output  <img src=“/img/chocCake.jpg” alt=“Chocolate Cake” />
  • 21. HtmlHelper - Script  Similar to the CSS Method  Parameters  First – String to a single JS file, or an array of JS files.      This is relative to the app/webroot/js folder Will also allow for directories outside webroot/js folder Can also take a path to a remote URL Second – optional associated array of options (html attributes) We will only focus on the first parameter  Example    echo $this->Html->script(“scripts”); echo $this->Html->script(“/newJSDirectory/scripts”); echo $this->Html->script(“http://www.somesites.com/jsFile.js”);  Notice you must include the extention  Output  <script type=“text/javascript” src=“/js/scripts.js”></script>
  • 22. FormHelper  Basic Function of the FormHelper    The FormHelper generates the needed code for form creation Creates forms quickly Streamlines validation, re-population and layout.  Lots of Methods  The FormHelper has a lot of methods. We will be covering the following:       create end hidden password input We will cover the general basics of each of them  Link to FormHelper  http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html
  • 23. FormHelper - Create  Parameters   First – optional string model name Second – optional associated array of options  Defaults  Form method defaults to ‘post’  Example  General Add or Edit form with Model  echo $this->Form->create(“Items”);  Output   <form id=“ItemAddForm” method=“post” action=“/items/add”> If Edit form   <form id=“ItemEditForm” method=“post” action=“/items/edit/5”> <input type=“hidden” name=“_method” value=“PUT” />
  • 24. FormHelper - End  Single Parameter Optional   String name for submit button or Associated array of options  Example   echo $this->Form->end(); echo $this->Form->end(“Add Item”);  Output   </form> <div class=“submit”> <input type=“submit” value=“Add Item” /> </div> </form>
  • 25. FormHelper - Hidden  Parameters   First - string field name Second – optional associated array of options  Example  echo $this->Form->hidden(“id”);  Output  <input name=“data[Item][id]” value=“16” id=“ItemId” type=“hidden” />
  • 26. FormHelper - Password  Parameters   First - string field name Second – optional associated array of options  Example  echo $this->Form->password(“password”);  Output  <input name=“data[User][password]” value=“” id=“UserPassword” type=“password” />
  • 27. FormHelper - Input  Parameters   First – string field name Second – optional associated array of options  Basic Understanding  Output of an input method     div container label tag input tag error element (if applicable)
  • 28. FormHelper - Input  Basic Understanding Cont’d   The input method determines what type of input you need based on the field that is provided (first parameter). Below is a list of associations based on column type Column Type Form Field string (char, varchar, etc.) text boolean, tinyint(1) checkbox text textarea text (field name of password, passwd, psword) password text (field name of email) email text (field name of tel, telephone, phone) tel date day, month, and year selects datetime day, month, year, hour, minute, and meridian selects time hour, minute, and meridian selects
  • 29. FormHelper - Input  Input Options    Optional Associated array, key/value pairs Below is a list of a few different types of options available. The full list can be found here  http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#options  Options List  Type – Force the type of input to be used   Label – provide personal text for the label tag   Example – ‘default’ => ‘Chocolate Cake’ Selected – set a selected option based on the value provided   Example – ‘label’ => ‘First Name’ Default – set the default value of the field   Example - ‘type’ => ‘email’ Example – ‘selected’ => ‘3’ Rows, Cols – set the rows and columns of a text area  Example – ‘rows’ => ‘5’, ‘cols’ => ‘10’
  • 30. FormHelper - Input  Example – Add an Item Form  Example – Edit an Item Form
  • 31. Summary  Four Parts of the View     Layout Views Elements Helpers  Layout  Views  Extending Views  Elements  Reusable code  Helpers   Code shortcuts HtmlHelper, FormHelper