Yii Framework: Create a link with multiple parameters CHTML::link

yii
14,536

Solution 1

Documentation: http://www.yiiframework.com/wiki/48/by-example-chtml/

<?php echo CHtml::link('Link Text',array('controller/action',
                                     'param1'=>'value1',
                                     'param2'=>'value2',
                                     'param3'=>'value3')); ?>

Solution 2

<?php echo CHtml::link('Link Text',
                       Yii::app()->createUrl('controller/action',array(
                                                         'param1'=>'value1',
                                                         'param2'=>'value2',
                                                         'param3'=>'value3')); ?>
Share:
14,536
John Zumbrum
Author by

John Zumbrum

John Zumbrum, Software Engineering Lead and Product Designer Passionate about the full software development life cycle from concept through deployment, and excited about crafting meaningful web applications and businesses. Specialties: PHP, Python, Flask, MySQL, MongoDB, C#, ASP.NET MVC, SQL Server, Web Applications

Updated on June 28, 2022

Comments

  • John Zumbrum
    John Zumbrum almost 2 years

    I would like to link to a different controller, passing in multiple parameters.

  • John Zumbrum
    John Zumbrum almost 12 years
    Can you provide a little more detail to explain what advantages the createUrl method provides in this case?
  • adamors
    adamors almost 12 years
    There are no advantages in this case, the link will be parsed the same way.