Yii 1.1: viewlogger

Log the name of views in the html

Have you ever tried to open a project after a while and think: "I know that this html lies in some view, maybe some controller view... maybe a sub-view or some widget view...."

Now this problem is solved! Just install this widget, set a new debug constant (LOG_VIEW_NAMES) and you will get developer-friendly comments in your html like:

<!-- BEGIN C:\www\mySite\protected\components\views\hotelList\list.php -->
/* all view html */
<!-- END C:\www\mySite\protected\components\views\hotelList\list.php -->

Usage ΒΆ

Unzip the content in an included folder (components, for example).

Make all your controller to extend the loggin controller:

class MyController extends ZLoggingController

If you use Gii generated application, you already have a masterclass for controller. Just edit the first line of the file protected/components/Controller.php:

class Controller extends ZLoggingController

And all views and subviews will be logged.

For log widgets, edit widgets in order to extend the class logging widget:

class MyWidget extends ZLoggingWidget

The log will not be displayed as default. If you want to log, add this line in index.php:

defined('LOG_VIEW_NAMES') or define('LOG_VIEW_NAMES',true);

Total 7 comments

#5075 report it
zaccaria at 2011/09/13 05:08am
Thank you radoo

Thank for the fix, I corrected the extension.

With this detail it works correctly also with IE9!

Abuout your question, I am patiently editing all controller classes.

#5074 report it
radoo at 2011/09/13 04:55am
pseudo-bug fix

The ending tag for the HTML comment you are using should be --> and not --!> While browsers seem to not have a problem with it, there are certain cases when this gets in the way of development.

I am also curious about how you and other people solved the problem of having to extend Controller from some other needed class, such as RController (when using the "rights" module for example) but still needed to use viewlogger..

Other than that, an excellent small extension that I am using regularly.

#3509 report it
got 2 doodle at 2011/04/16 10:27am

I love this, very simple to use and wow! It will definitely save time especially when returning to a project.

Two thumbs way up! doodle

#3487 report it
zaccaria at 2011/04/15 02:10am
re: rudiedirkx

You are 100% right.

I updated the extension prepending my beloved 'Z as Zaccaria' in order to avoid such conflicts.

Thank you very much for pointing this problem.

#3480 report it
Dudie Rirkx at 2011/04/14 03:48pm
controller name

What happens if you want a controller named LoggingController so you can have paths /logging/*?

The base controller name should have another format: something entirely different from actual web controllers.

#3445 report it
zaccaria at 2011/04/13 12:49pm
Thank you!

I run in this problem this morning, and I was amazed about how a 5 minute work can save you lot of boring searching time.

I am really glad you appreciate!

#3440 report it
pappleton at 2011/04/13 05:12am
Nice idea

Thanks for sharing the idea.

Leave a comment

Please to leave your comment.

Create extension