Jump to content
Larry Ullman's Book Forums
KeepLearning

Page Titles In Views: Controller Instance Or Action?

Recommended Posts

Version 0.5

 

Two questions about page 115.

 

1. Quoting from the book: 

 

"<?php $this->pageTitle = Yii::app()->name . '::' . $model->title; ?>"

 

Why are there two colons before $model->title ? I assume they will appear literally, but maybe they function as code -- I'm not sure.

 

 

2. Quoting from the book again: 

 

"{TIP} Because the page title is set by assigning a value to the controller instance, it can also be set within the controller action, if you’d rather."

 

This sentence is saying 2 things, neither of which I understand. Larry, can you please break this down and provide an example? 

 

Thanks.

Share this post


Link to post
Share on other sites

Actually, no, those aren't being used as code there (as the scope resolution operator). Those are just literal. 

Share this post


Link to post
Share on other sites

Thanks for the answer Larry.

 

And how about question 2? Here's the sentence I'm confused about again. An example would be really helpful. Thanks. 

 

 
p 115. 
 
"{TIP} Because the page title is set by assigning a value to the controller instance, it can also be set within the controller action, if you’d rather."

Share this post


Link to post
Share on other sites

 

Thanks for the answer Larry.

 

And how about question 2? Here's the sentence I'm confused about again. An example would be really helpful. Thanks. 

 

 
p 115. 
 
"{TIP} Because the page title is set by assigning a value to the controller instance, it can also be set within the controller action, if you’d rather."

 

In the view file:

 

 

<?php $this->pageTitle = Yii::app()->name . '::' . $model->title; ?>
 

 

 

Or in a controller action, such as PageController.php::actionView():

 

 

<?php $this->pageTitle = Yii::app()->name . '::' . $model->title; ?>
 

 

 

The same code works in either place.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...