私はcakephp 2.2を使用しています
かわいいURLを持つようにルーターを構成しています
html リンクが変更されず、最初の結果で動かなくなる
以下のコードは機能し、私が望むことを行いますが、リンクを生成する方法を使用しようとしています
<td><a href="/<?php echo $examples['somemodel']['slug'];?>"><?php echo $examples['somemodel'][slug'];?> </a></td>
これを行うと、URL名は異なりますが、ハイパーリンクは変更されません
<?php echo
$this->Html->link($examples['model']['somename'], '/controllername/slug/' + $examples['model']['slug']);
?>
私の結果は
<a href =”/example1”>example1 </a>
<a href =”/example1 ”>example2 </a>
<a href =”/example1 ”>example3 </a>
<a href =”/example1”>example4 </a>
私がやりたいことの代わりに
<a href =”/example1”>example1 </a>
<a href =”/example2”>example2 </a>
<a href =”/example3”>example3 </a>
ご覧のとおり、URL 名は異なりますが、ハイパーリンクは変わりません
//router.php Router::connect(
"/example/:slug",
array('controller' => 'differentname', 'action' => 'view'),
array(
'name'=>'[-A-Z0-9]+',
'pass' => array('slug')
)
);
Router::connectNamed(
array('/example/' => array('action' => 'view', 'controller' => 'different')),
array('default' => true, 'greedy' => true)
);
//'view.ctp
<?php
foreach ($example as $examples): ?>
<?php echo
$this->Html->link($examples['model']['somename'], '/controllername/slug/' + $examples['model']['slug']);
?>
結果 example1 example2 example3 example4
それ以外の
<a href =”/example1”>example1 </a>
<a href =”/example2”>example2 </a>
<a href =”/example3”>example3 </a>
私が見逃しているもの、またはここに到達していないもの