<div class="page-header">
<h1>Gérer les pages</h1>
</div>
<table class="table">
<tr>
<th>ID</th>
<th>Nom</th>
<th>En ligne</th>
<th>Action</th>
</tr>
<?php foreach($pages as $k=>$v) $v = current ($v);?>
<tr>
<td>ID</td>
<td>Nom</td>
<td>En ligne</td>
<td>Action</td>
</tr>
</table>
<?php
class AppController extends Controller {
function beforeFilter(){
if(isset($this->request->params['prefix']) && $this->request->params['prefix'] == 'admin')
$this->layout = 'admin';
}
}
<?php
class Post extends AppModel{
public function afterFind($data , $primary = false){
foreach($data as $k=>$d){
if(isset($d['Post']['slug']) && isset($d['Post']['id'])){
$d['Post']['link'] = array(
'controller' => 'pages',
'action' => 'show',
'id' => $d['Post']['id'],
'slug' => $d['Post']['slug']
);
}
$data[$k] = $d;
}
return $data;
}
}
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $title_for_layout; ?></title>
<?php echo $this->Html->css('bootstrap.min');?>
<?php echo $scripts_for_layout; ?>
</head>
<body>
<div class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<h3><a href="#">Administration</a></h3>
</div>
<div class="collapse navbar-collapse">
<ul class='menu'>
<?php echo $this->Html->link("Pages",array('action'=>'index','controller' =>'pages'));?></li>
</div><!--/.nav-collapse -->
</div>
</div>
<div class ="container">
<?php echo $content_for_layout; ?>
</div>
<?php echo $this->element('sql_dump');?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<?php echo $this->Html->script('bootstrap.min');?>
</body>
<?php $pages = $this->requestAction(array('controller'=>'pages','action'=> 'menu')); ?>
<ul class="nav navbar-nav">
<?php foreach($pages as $k=>$v): $v = current($v); ?>
<li><?php echo $this->Html->link($v['title'],$v['link']); ?></li>
<?php endforeach ?>
</ul>
I don(t insert the code <?php foreach($pages as $k=>$v) $v = current ($v);?> in my admin_index
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment