TopsControllerからTasksControllerで使ったテーブルTasksテーブルの内容を表示したい。
自力で色々試してみたのですが・・・
下記のサイトをみて試してみたのですが上手く行きませんでした。
http://phptips.seesaa.net/article/93464170.html
ヒントなど有りましたらよろしくお願いします。
TopsController.php
php
1 2<?php 3class TopsController extends AppController { 4 var $name = 'Tops'; 5 var $uses=array('top','task'); 6 public $helpers = array('Html', 'Form'); 7 public $components = array('Session'); 8 public $paginate = array( 9 'limit' => 10, 10 'sort'=>'created', 11 'direction'=>'desc', 12 'paramType' => 'querystring', 13 14 ); 15 public function index() { 16 //テンプレート変更 17$this->layout = 'bootstrap'; 18 19$this -> set('tasks', $this->paginate()); 20 } 21} 22?>
Tops/index.ctp
php
1<table class="table table-striped table-hover"> 2<?php echo $this->Html->tableHeaders(array('登録日','提供元','内容', '予算', 'カテゴリ')); ?> 3<?php foreach ($tasks as $task){?> 4<?php $urls=$task['Task']['url'];?> 5<?php echo $this->Html->tableCells(array( 6 $this->Time->format($task['Task']['created'],'%m-%d'), 7 $task['Company']['company_name'], 8 $this->Html->link ( $task['Task']['title'],$urls,array( 'target' => '_blank' ) ), 9 $task['Task']['price'], 10 $task['Task']['category'])); 11?> 12<?php }?> 13</table>
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。