I have many view like Shops, Categories, Products, Toppings….
And using the hardcoded Model names very often. Sometimes singular ot plural. like in the Shop's index.ctp
<ul class="nav nav-tabs">
<li><?php echo $this->Html->link(__('New Shop'), array( 'action' => 'add'));?></li>
</ul>
<div class="page-header">
<h1><?php echo __('Shops'); ?></h1>
</div>
AND
<td><?php echo $shop['Shop']['id']; ?>
<td><?php echo $shop['Shop']['name']; ?>
<td><?php echo $shop['Shop']['street']; ?>
...
Is there a better way to dynamically use the model names?
Thank you.
Well, you can add
$myshop = $shop['Shop'];at the top of your code so you can use$myshop['id']but thats pretty much it. It’s not weird to use variables where you need them.