お世話になります。
CakePHP、PHP、MySQLを使用したサイト構築の勉強中の身です。
現在、ログイン中の画面遷移の作りこみをしている最中ですが、
表題のタイトルのエラーの解消方法を公式ドキュメントを含め、
参考となりそうなページのコードを試しましたが改善できません。
解決したいこと:
【現在】現在ログイン中のユーザー名をクリック⇒エラー
【今後】現在ログイン中のユーザー名をクリック⇒ログイン中ユーザーのプロフィール画面へ遷移できるようにする(/my_pt_lesson/src/Template/Users/view.ctpの画面)
下記の画面図と、ソースコードを元に、
どのように手を加えれば解決するのか、
ご教示いただけると幸いです。
※現時点で足りると思われる内容を掲載しましたが、
不足の点がありましたら、その部分も改めて掲載しますので、
ご指摘、よろしくお願いいたします。
▽現在制作中のトップ画面(ユーザーログイン後)▽
▽ログイン中のユーザー名をクリックすると...▽
▽このようなエラー表記がでます▽
▽また、/my_pt_lesson/src/Template/Ices/index.ctpで構成されているリンク(チユーザー名)をクリックすると...▽
▽/my_pt_lesson/src/Template/Users/view.ctpで構成されたページへ遷移します▽
■現在のソースコードは以下の通りです。
※文字数制限の関係上、コメント等、不要な部分は削除してあります。
▽CakePHPのctpファイル▽
/my_pt_lesson/src/Template/Layout/my_layout.ctp(一部抜粋)
<!DOCTYPE html> <html> <head> <?= $this->Html->charset() ?> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> <?= $cakeDescription ?>: <?= $this->fetch('title') ?> </title> <?= $this->Html->meta('icon') ?> <?= $this->Html->css('base.css') ?> <?= $this->Html->css('style.css') ?> <?= $this->fetch('meta') ?> <?= $this->fetch('css') ?> <?= $this->fetch('script') ?> </head> <body> <h1>IceCream Mania</h1> <ul> <?php if ($this->request->getSession()->read('Auth.User')): ?> <li><?= $this->Html->link($this->request->getSession()->read('Auth.User.nickname') . "様", ['controller' => 'Users', 'action' => 'view']) ?></li> <li><?= $this->Html->link('アイスの一覧', ['controller' => 'ices', 'action' => 'index']) ?></li> <li><?= $this->Html->link('ログアウト', ['controller' => 'users', 'action' => 'logout']) ?></li> <?php else: ?> <!--<li><?= $this->Html->link('ログイン', ['controller' => 'users', 'action' => 'login']) ?></li>--> <?php endif ?> </ul> <?= $this->Flash->render() ?> <div class="container clearfix"> <?= $this->fetch('content') ?> </div> <footer> </footer> </body> </html>
/my_pt_lesson/src/Template/Ices/index.ctp(一部抜粋)
<?php <div class="ices index large-9 medium-8 columns content"> <h3><?= __('Ices') ?></h3> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th scope="col"><?= $this->Paginator->sort('id') ?></th> <th scope="col"><?= $this->Paginator->sort('user_id') ?></th> <th scope="col"><?= $this->Paginator->sort('manufacturer') ?></th> <th scope="col"><?= $this->Paginator->sort('ice_name') ?></th> <th scope="col"><?= $this->Paginator->sort('ice_fraver') ?></th> <th scope="col"><?= $this->Paginator->sort('simple_comment') ?></th> <th scope="col"><?= $this->Paginator->sort('price_no_tax') ?></th> <th scope="col"><?= $this->Paginator->sort('buy_year') ?></th> <th scope="col"><?= $this->Paginator->sort('buy_month') ?></th> <th scope="col"><?= $this->Paginator->sort('image_file') ?></th> <th scope="col"><?= $this->Paginator->sort('created') ?></th> <th scope="col"><?= $this->Paginator->sort('modified') ?></th> <th scope="col" class="actions"><?= __('Actions') ?></th> </tr> </thead> <tbody> <?php foreach ($ices as $ices): ?> <tr> <td><?= $this->Number->format($ices->user->id) ?></td> <td><?= $ices->has('user') ? $this->Html->link($ices->user->nickname, ['controller' => 'Users', 'action' => 'view', $ices->user->id]) : '' ?></td> <td><?= h($ices->manufacturer) ?></td> <td><?= h($ices->ice_name) ?></td> <td><?= h($ices->ice_fraver) ?></td> <td><?= h($ices->simple_comment) ?></td> <td><?= $this->Number->format($ices->price_no_tax) ?></td> <td><?= $this->Number->format($ices->buy_year) ?></td> <td><?= $this->Number->format($ices->buy_month) ?></td> <td><?= h($ices->image_file) ?></td> <td><?= h($ices->created) ?></td> <td><?= h($ices->modified) ?></td> <td class="actions"> <?= $this->Html->link(__('View'), ['action' => 'view', $ices->id]) ?> <?= $this->Html->link(__('Edit'), ['action' => 'edit', $ices->id]) ?> <?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $ices->id], ['confirm' => __('Are you sure you want to delete # {0}?', $ices->id)]) ?> </td> </tr> <?php endforeach; ?> </tbody> </table> <div class="paginator"> <ul class="pagination"> <?= $this->Paginator->first('<< ' . __('first')) ?> <?= $this->Paginator->prev('< ' . __('previous')) ?> <?= $this->Paginator->numbers() ?> <?= $this->Paginator->next(__('next') . ' >') ?> <?= $this->Paginator->last(__('last') . ' >>') ?> </ul> <p><?= $this->Paginator->counter(['format' => __('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')]) ?></p> </div> </div>
/my_pt_lesson/src/Template/Users/view.ctp(一部抜粋)
<!DOCTYPE html> <html> <head> <?= $this->Html->charset() ?> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> <?= $cakeDescription ?>: <?= $this->fetch('title') ?> </title> <?= $this->Html->meta('icon') ?> <?= $this->Html->css('base.css') ?> <?= $this->Html->css('style.css') ?> <?= $this->fetch('meta') ?> <?= $this->fetch('css') ?> <?= $this->fetch('script') ?> </head> <body> <nav class="large-3 medium-4 columns" id="actions-sidebar"> <ul class="side-nav"> <li class="heading"><?= __('Actions') ?></li> <li><?= $this->Html->link(__('Edit User'), ['action' => 'edit', $user->id]) ?> </li> <li><?= $this->Form->postLink(__('Delete User'), ['action' => 'delete', $user->id], ['confirm' => __('Are you sure you want to delete # {0}?', $user->id)]) ?> </li> <li><?= $this->Html->link(__('List Users'), ['action' => 'index']) ?> </li> <li><?= $this->Html->link(__('New User'), ['action' => 'add']) ?> </li> <li><?= $this->Html->link(__('List Ices'), ['controller' => 'Ices', 'action' => 'index']) ?> </li> <li><?= $this->Html->link(__('New Ice'), ['controller' => 'Ices', 'action' => 'add']) ?> </li> </ul> </nav> <div class="users view large-9 medium-8 columns content"> <h2><?= h($user->nickname."さんのプロフィール") ?></h2> <table class="vertical-table"> <tr> <th scope="row"><?= __('Profiel Comment') ?></th> <td><?= h($user->profiel_comment) ?></td> </tr> <tr> <th scope="row"><?= __('Created') ?></th> <td><?= h($user->created) ?></td> </tr> <tr> <th scope="row"><?= __('Modified') ?></th> <td><?= h($user->modified) ?></td> </tr> </table> <div class="related"> <h4><?= __('Related Ices') ?></h4> <?php if (!empty($user->ices)): ?> <table cellpadding="0" cellspacing="0"> <tr> <th scope="col"><?= __('メーカー') ?></th> <th scope="col"><?= __('アイスの名前') ?></th> <th scope="col"><?= __('フレーバー') ?></th> <th scope="col"><?= __('価格(税抜)') ?></th> <th scope="col"><?= __('購入年') ?></th> <th scope="col"><?= __('購入月') ?></th> <th scope="col"><?= __('アイスの画像') ?></th> <th scope="col"><?= __('登録日') ?></th> <th scope="col"><?= __('更新日') ?></th> <th scope="col" class="actions"><?= __('Actions') ?></th> </tr> <?php foreach ($user->ices as $ices): ?> <tr> <td><?= h($ices->manufacturer) ?></td> <td><?= h($ices->ice_name) ?></td> <td><?= h($ices->ice_fraver) ?></td> <td><?= h($ices->price_no_tax) ?></td> <td><?= h($ices->buy_year) ?></td> <td><?= h($ices->buy_month) ?></td> <td><?= h($ices->image_file) ?></td> <td><?= h($ices->created) ?></td> <td><?= h($ices->modified) ?></td> <td class="actions"> <?= $this->Html->link(__('詳細'), ['controller' => 'Ices', 'action' => 'view', $ices->id]) ?> <?= $this->Html->link(__('編集'), ['controller' => 'Ices', 'action' => 'edit', $ices->id]) ?> <?= $this->Form->postLink(__('削除'), ['controller' => 'Ices', 'action' => 'delete', $ices->id], ['confirm' => __('Are you sure you want to delete # {0}?', $ices->id)]) ?> </td> </tr> <?php endforeach; ?> </table> <?php endif; ?> </div> </div>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/09/15 07:09
2019/09/15 07:12
2019/09/15 07:51