I’m new to cakephp. I don’t want to display a column, but, removing it, from view.ctp doesn’t seem to take any affect? Why is that? Also, I have two tables X and Y. But view.ctp for X is showing the Y columns? and the Y view.ctp is showing the X columns? What gives?
Are you sure you’re changing the right file?
Typically, view.ctp shows a single instance of a record, and index.ctp shows a list of records.
If X and Y have a relationship, then the view.ctp for X might list the related Y records.
To prevent confusion, it’s probably better to give code of the view.ctp you are changing, and the actual output as HTML or a screenshot.
Hi,
Thanks for the reply. X and Y have many-to-many relationship.
I ran “cake bake all X” and "cake bake all Y"
X is staff
Y is client.
under src->template->staffs->view.ctp
when I change this file ( delete some of the columns from the table because I don’t want to display all of them), save, refresh the page, not seeing any changes
- <?= __('Actions') ?>
- <?= $this->Html->link(__('Edit Staff'), ['action' => 'edit', $staff->id]) ?>
- <?= $this->Form->postLink(__('Delete Staff'), ['action' => 'delete', $staff->id], ['confirm' => __('Are you sure you want to delete # {0}?', $staff->id)]) ?>
- <?= $this->Html->link(__('List Staffs'), ['action' => 'index']) ?>
- <?= $this->Html->link(__('New Staff'), ['action' => 'add']) ?>
- <?= $this->Html->link(__('List Locations'), ['controller' => 'Locations', 'action' => 'index']) ?>
- <?= $this->Html->link(__('New Location'), ['controller' => 'Locations', 'action' => 'add']) ?>
- <?= $this->Html->link(__('List Clients'), ['controller' => 'Clients', 'action' => 'index']) ?>
- <?= $this->Html->link(__('New Client'), ['controller' => 'Clients', 'action' => 'add']) ?>
<?= h($staff->id) ?>
So, you deleted some related client columns from the staff view template,
and they are still showing when you view a particular staff member?
You may need to check for caching. In the browser, ensure caching is
disabled. Check there are not any cached views in app/tmp/cache/views.
Also make sure you are hitting the right action and view. Use Xdebug to
trace it through, or logging in the controller and view to ensure they
right ones are being hit.
Hi,
I was changing view.ctp, but, it’s index.ctp that’s being displayed ( not view.ctp )
what is view.ctp used for?
oh well, I only wasted 4 days; to change something trivial.
By the way, how do I remove that stupid red strip that’s displayed at the bottome of the screen?
regards
The view.ctp is used when you are looking at a single record, rather than a list of records.
With regards to the red strip, locate the HTML and CSS and remove it from there. If it’s on all the screens, most likely it’s in the layout.ctp. If it’s only a few screens, then it will be a part of the view template for that screen.
The red strip is likely the debug toolbar for CakePHP (DebugKit). You can click the Cake icon to minimize it. If you want to remove the plugin entirely, delete Plugin::load('DebugKit', ['bootstrap' => true]);
from your application’s config/bootstrap.php
file.