pisfrontpage Tells whether the current page is front page or not

  1. General
  2. Requirements
  3. Installation
  4. One last word
  5. Resources
  6. Change Log

That's ought to be one of the smallest Yii extensions around... .

General

  • Its very common to have some construct in view files along the lines of:
if this is front-page
    print some stuff
end if
  • I wasn't able to find some ready made thing that can tell me just that in Yii so I created this extension.
  • Its a simple behavior component that is attached to the 'web application'.
  • Once attached, it can be used as demonstrated below:
<?php 
if (Yii::app()->isFrontPage()) {
  // render special widgets, print some stuff, etc...
}
?>

Requirements

The requirements are really minimal :) . Just make sure to follow the installation instructions and you're clear for takeoff.

Installation

  • Extract the contents of this package. Put the resulted php class file under /protected/components
  • Inside main.php config file:
// ...
'behaviors' => array(
    'isFrontPageTeller' => array(
        'class' => 'application.components.PcIsFrontpage',
    )
),
// ...
  • That's it! I told you it would be simple.

One last word

I have some doubts that this isn't achievable by other means. Also, maybe you have some reservations on the implementation (the behavior method implementation). In case you have this important feedback please do not spare it from me :) ... (TIA)

Resources

Change Log

  • 11 July 2012 v1.1: bugfix: stripping query string from checked url before determining if is front page
1 0
4 followers
707 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Others
Developed by: Boaz
Created on: Jul 8, 2012
Last updated: 12 years ago

Downloads

show all

Related Extensions