Reputation: 431
I'm very new to Yii 2.03 (and frameworks in general). I'm facing some problem now.
On the main page I have a menu on which I want to place (in the view) the link to the controller, but I don't know how, I'm getting " PHP Fatal Error – yii\base\ErrorException Class 'CHtml' not found" or " PHP Fatal Error – yii\base\ErrorException Class 'Html' not found"
http://localhost/web/index.php
is the main page with the menu.
http://localhost/web/index.php?r=autori/index
is the page with the generated CRUD, which works perfectly.
In the view I have <li><a href="#">Autori</a></li>
and I want to replace the '#' with a valid link, I don't care for SEO now. How can I edit the view to use the specific controller?
Thanks!
Upvotes: 1
Views: 346
Reputation: 76
If you are indeed using Yii2, then try using:
<li><a href="<?=Url::to(["autori/index"])?>">Autori</a></li>
You'll need to include this in the beginning of your view file, so it uses the correct namespace for the Url helper class:
<?php use yii\helpers\Url ?>
But pay attention to the framework version, as Sliq noted, CHtml is a Yii1 class.
Upvotes: 2