Yii 1.1: browsehistory

Browsehistory memories a limited list of last visited pages (route + title).
6 followers

BrowseHistory

This Yii extension manages a history of the last visited pages. Browsehistory memories a limited list of last visited pages (route + title).

Requirements

  • PHP 5 >= 5.1.0
  • Yii 1.0

Usage

First, unzip the archive into protected/extensions/browsehistory/, and change the file permissions. Note: only protected/extensions/browsehistory/models/Browsehistory.php is used. The other files are for development purpose.

Add 'ext.browsehistory.models.Browsehistory' in the import section of the configuration or use Yii::import() as in the following examples.

Add a page

In a view, or in a controller, add a new page using:

Yii::import('ext.browsehistory.models.Browsehistory');
$maxNbOfRoutes = 20;
$history = Browsehistory::getInstance('session-key', $maxNbOfRoutes);
$history->push(array('/site/index', 'Homepage');

or using the default values

Yii::import('ext.browsehistory.models.Browsehistory');
$history = Browsehistory::getInstance();
$history->push(null, $this->pageTitle);

Display the history

And the list can be displayed in a CMenu. For example, I'm using it in the main application menu (the famous horizontal menu) or in a CPortlet, in a vertical menu.

Yii::import('ext.browsehistory.models.Browsehistory');
$history = Browsehistory::getInstance();
$this->widget('zii.widgets.CMenu', array(
    'items'=>$history->items(),
));

or

$items = array(
    array('label'=>'Home',
        'url'=>array('/default/index'),
    )
);
 
// import and add items into a set of CMenu items
Yii::import('ext.browsehistory.models.Browsehistory');
$history = Browsehistory::getInstance();
$history->addItems($items);
 
// render the menu
$this->widget('zii.widgets.CMenu', array(
    'items'=>$items,
));

Total 3 comments

#6807 report it
jacmoe at 2012/02/06 01:28pm
Re: License GPL

Sorry. I am not going to touch library code with the GPL license. That is by principle. I prefer to use MIT, BSD, Zlib and compatible licenses. GPL is perfectly fine for applications, not for third-party libraries/extensions.

MIT is GPL-compatible, by the way. So it wouldn't be in conflict with your application.

Besides that nitpick, it's a great idea for an extension. :)

#6803 report it
Eliovir at 2012/02/06 08:57am
License GPL

The choice is not excessive. It is the same as the whole project for which it is developed. Project developed in GPL as it uses GPL libraries... and GPL is also my choice.

But choices of license is always matter of questions...

Feel free to comment on the code, features, documentation, ...

#6768 report it
jacmoe at 2012/02/03 11:57am
License?

GPL? Seriously?! Really excessive choice of license. Especially for a one-file extension like this. Could you change the license to MIT or similar, please? :)

Leave a comment

Please to leave your comment.

Create extension