I have routers configured to have pretty urls
html link not changing stuck on first result
the below code works and does what I want, but I am trying to use cakes way of generating links
<td><a href="/<?php echo $examples['somemodel']['slug'];?>"><?php echo $examples['somemodel'][slug'];?> </a></td>
when I do this the url name is different
but the hyper link doesn't change
<?php echo
$this->Html->link($examples['model']['somename'], '/controllername/slug/' + $examples['model']['slug']);
?>
my results are
<a href ="/example1">example1 </a>
<a href ="/example1 ">example2 </a>
<a href ="/example1 ">example3 </a>
<a href ="/example1">example4 </a>
instead of what I want it to do
<a href ="/example1">example1 </a>
<a href ="/example2">example2 </a>
<a href ="/example3">example3 </a>
as you can see the url name is different
but the hyper link doesn't change
//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']);
?>
results
<a href ="/example1">example1 </a>
<a href ="/example1 ">example2 </a>
<a href ="/example1 ">example3 </a>
<a href ="/example1">example4 </a>
instead of
<a href ="/example1">example1 </a>
<a href ="/example2">example2 </a>
<a href ="/example3">example3 </a>
What am I missing or not getting here
-- Like Us on FacekBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
No comments:
Post a Comment