Friday, September 28, 2012

Re: Html link not changing url location

Sorry for the ignorance, what do you mean?

On Friday, September 28, 2012 12:38:52 PM UTC-7, Léo Willian Kölln wrote:
Why not use Routing Array on the Html::link() ?

Léo Willian Kölln


On Tue, Sep 25, 2012 at 2:28 PM, arron <w...@wwisinc.com> wrote:
I have configured routes.php so i can have pretty urls 

it works when i do this 
<td><a href="/<?php echo $examples['model']['somename'];?>"><?php echo $examples['somemodel']['slug'];>?></a></td>

but I am trying to use cakes way for generating links  

$this->Html->link($examples['model']['somename'], '/controllername/slug/' + $examples['model']['slug']);

when I use  $this->Html-> link the url location doesn't change.  



The url name is different 
but the hyper link doesnt change and is stuck on the first result 


<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> 



//router.php
Router::connect(

    "/example/:slug",
    array('controller' => 'somecontrollername', 'action' => 'view'),
           array( 
   
'name'=>'[-A-Z0-9]+', 

               'pass' => array('slug')

  

     ) 

);
Router::connectNamed(
    array('/example/' => array('action' => 'view', 'controller' => 'somecontrollername')),
    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']);
?>

result 

<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> 




any help would be great 

--
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...@googlegroups.com.
To unsubscribe from this group, send email to cake-php+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

--
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: