atti
(Atti84it)
1
I’m using CHtml::link inside a module (called ‘admin’)
Depending on how is called the page I may get broken links:
<?php echo CHtml::link(‘Mycontroller’, ‘mycontroller’); ?>
will produce myapp/admin/mycontroller if I open myapp/admin/
will produce myapp/mycontroller if I open myapp/admin
<?php echo CHtml::link(‘Mycontroller’, ‘admin/mycontroller’); ?>
will produce myapp/admin/admin/mycontroller if I open myapp/admin/
will produce myapp/admin/mycontroller if I open myapp/admin
no way using <?php echo CHtml::link(‘Mycontroller’, ‘/admin/mycontroller’); ?>
this will produce localhost/admin/mycontroller, without myapp.
is there a way to be SURE that I will not get broken links?
gusnips
(Gustavo)
2
use "mycontroller/" that will use the default action of "mycontroller"
atti
(Atti84it)
3
Sorry it doesn’t solve the problem:
<?php echo CHtml::link(‘Mycontroller’, ‘mycontroller/’); ?>
will produce myapp/admin/mycontroller/ if I open myapp/admin/ --> OK
will produce myapp/mycontroller/ if I open myapp/admin --> BROKEN LINK!!
gusnips
(Gustavo)
4
try
echo CHtml::link('Mycontroller', array('mycontroller/')); //url as array
that will use CUrlManager to create the url
atti
(Atti84it)
5
yep
it works!! thank you!!