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,
));
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? :)
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, ...
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. :)
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.