Version: current

     1 <?php
     2 /**
     3  * SSNController adds a new method to Content Controller, this replaces the default Silverstripe
     4  * Navigator. Instead of hard codede links, SSNavigator should allow URL's in the navigator to
     5  * be altered a bit more easily and should allow for custom templating within the users
     6  * Templates folder.
     7  *
     8  * To add The new navigator bar, add $SSNavigator to your template, in place of the traditional
     9  * $Silverstripenavigator
    10  */
    11 class SSNController extends Extension {
    12     protected $dataRecord;
    13
    14     /**
    15      * @var $adminLink Link to the main admin area
    16      */
    17     static $adminLink = 'admin';
    18
    19     public function SSNavigator() {
    20         if(Director::isDev() || Permission::check('CMS_ACCESS_CMSMain')) {
    21             Requirements::css(SAPPHIRE_DIR . '/css/SilverStripeNavigator.css');
    22
    23             Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js');
    24             Requirements::customScript(<<<JS
    25                 Behaviour.register({
    26                     '#switchView a' :  {
    27                         onclick : function() {
    28                             var w = window.open(this.href,windowName(this.target));
    29                             w.focus();
    30                             return false;
    31                         }
    32                     }
    33                 });
    34
    35                 function windowName(suffix) {
    36                     var base = document.getElementsByTagName('base')[0].href.replace('http://','').replace(/\//g,'_').replace(/\./g,'_');
    37                     return base + suffix;
    38                 }
    39                 window.name = windowName('site');
    40 JS
    41             );
    42
    43             $this->owner->cmsLink   = self::$adminLink."/".CMSMain::$url_segment."/show";
    44             $this->owner->adminLink = self::$adminLink;
    45
    46             if($date = Versioned::current_archived_date()) {
    47                 $this->owner->DisplayMode ='Archived';
    48                 $this->owner->ArDate = Object::create('Datetime', $date, null);
    49             } else
    50                 $this->owner->DisplayMode = Versioned::current_stage();
    51
    52
    53             return $this->owner->renderWith('SSNavigator');
    54         }
    55     }
    56 }
    57 ?>

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -