Heshan Perera
Heshan Perera

Reputation: 4630

Yii Framework Tutorial - file not found

I am in the process of learning the Yii Framework. I have been following this

Tutorial. I have followed all the steps and have by index page loading. In my index.php page I point to two other pages located in

protected/views/message

The following is the code in my index.php located in the message folder mentioned above.

<html>
<body>
    <h1>Welcome</h1>
    <p> To view our message go to... <?php echo CHtml::link('Here', '/message/show')?> </p>
    <p> To edit our message go to... <?php echo CHtml::link('Here', '/message/edit')?> </p>
</body>
</html>

"message" is the ID I gave when generating the model and controller through the yii shell application.

The problem is, after the above page loads, and I click on any one of the above URLs, it points to

"localhost:8080/message/show"

and

"localhost:8080/message/edit"

, whereas the real location of these files is

"localhost:8080/test/protected/views/message/..."

What could I be doing wrong ?

Upvotes: 0

Views: 3038

Answers (2)

Dmitry Dedov
Dmitry Dedov

Reputation: 1106

Just read Yii tutorial, it's really good. Topic about URL Managment is suitable for your question, you can find answers. (by the way, Yii has only one entry point - index.php, there is no direct access to files in 'protected' folder, 'protected' folder must be protected :) urlManager does special work for routing requests )

Upvotes: 2

Puigcerber
Puigcerber

Reputation: 10114

You have to use an array() as the second parameter:

<?php echo CHtml::link('Here', array('/message/show'))?>

Check normalizeUrl to understand it. Cheers.

Upvotes: 2

Related Questions