CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.1 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.1
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
    • Network
      • Email
      • Http
    • Routing
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • Helper
  • HelperCollection
  • JsonView
  • MediaView
  • ScaffoldView
  • ThemeView
  • View
  • ViewBlock
  • XmlView

Class ViewBlock

ViewBlock implements the concept of Blocks or Slots in the View layer. Slots or blocks are combined with extending views and layouts to afford slots of content that are present in a layout or parent view, but are defined by the child view or elements used in the view.

Package: Cake\View
Copyright: Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: Cake/View/ViewBlock.php

Properties summary

  • $_active protected
    array
    The active blocks being captured.
  • $_blocks protected
    array
    Block content. An array of blocks indexed by name.

Method Summary

  • active() public
    Get the name of the currently open block.
  • append() public

    Append to an existing or new block. Appending to a new block will create the block.

  • end() public
    End a capturing block. The compliment to ViewBlock::start()
  • get() public
    Get the content for a block.
  • keys() public
    Get the names of all the existing blocks.
  • set() public

    Set the content for a block. This will overwrite any existing content.

  • start() public
    Start capturing output for a 'block'
  • unclosed() public
    Get the names of the unclosed/active blocks.

Method Detail

active() public ¶

active( )

Get the name of the currently open block.

Returns
mixed
Either null or the name of the last open block.

append() public ¶

append( string $name , string $value = null )

Append to an existing or new block. Appending to a new block will create the block.

Calling append() without a value will create a new capturing block that needs to be finished with View::end(). The content of the new capturing context will be added to the existing block context.

Parameters
string $name
Name of the block
string $value optional null
The content for the block.
Throws
CakeException
when you use non-string values.

end() public ¶

end( )

End a capturing block. The compliment to ViewBlock::start()

See
ViewBlock::start()

get() public ¶

get( string $name )

Get the content for a block.

Parameters
string $name
Name of the block
Returns
The
block content or '' if the block does not exist.

keys() public ¶

keys( )

Get the names of all the existing blocks.

Returns
array
An array containing the blocks.

set() public ¶

set( string $name , string $value )

Set the content for a block. This will overwrite any existing content.

Parameters
string $name
Name of the block
string $value
The content for the block.
Throws
CakeException
when you use non-string values.

start() public ¶

start( string $name )

Start capturing output for a 'block'

Blocks allow you to create slots or blocks of dynamic content in the layout. view files can implement some or all of a layout's slots.

You can end capturing blocks using View::end(). Blocks can be output using View::get();

Parameters
string $name
The name of the block to capture for.

unclosed() public ¶

unclosed( )

Get the names of the unclosed/active blocks.

Returns
array
An array of unclosed blocks.

Properties detail

$_active ¶

protected array

The active blocks being captured.

array()

$_blocks ¶

protected array

Block content. An array of blocks indexed by name.

array()
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs