Skip to content

Instantly share code, notes, and snippets.

@monsat
Created February 28, 2012 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monsat/1931453 to your computer and use it in GitHub Desktop.
Save monsat/1931453 to your computer and use it in GitHub Desktop.
Side Bar View Block in Layout
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php echo $this->Html->charset(); ?>
<title><?php echo $title_for_layout; ?></title>
</head>
<body>
<div id="container">
<div id="header">
<h1><?php echo $this->Html->link($cakeDescription, 'http://cakephp.org'); ?></h1>
</div>
<div id="content">
<?php echo $this->Session->flash(); ?>
<?php echo $this->fetch('content'); ?>
</div>
<div id="sidebar">
<?php echo $this->fetch('sideBar'); ?>
</div>
<div id="footer"><?php echo $this->Html->link($this->Html->image('cake.power.gif', array('alt' => $cakeDescription, 'border' => '0')), 'http://www.cakephp.org/', array('target' => '_blank', 'escape' => false)); ?></div>
</div>
</body>
</html>
<?php
foreach ($users as $user) {
echo $this->Html->link($user['User']['name'], array('action' => 'view', $user['User']['id']));
echo '<br />';
}
?>
<?php
// Side Bar に記述
$this->append('sideBar'); // start() でも可
?>
<ul id="side">
<li><?php h($users[0]['User']['name']); ?></li>
<li><?php h($users[1]['User']['name']); ?></li>
<li><?php h($users[2]['User']['name']); ?></li>
</ul>
<?php
$this->end(); // ここまで
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment