Jump to:

23367 Posts in 18143 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » Number of site displays

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2 3
Go to End
Author Topic: 1863 Views
  • sebastiankozub
    Avatar
    Community Member
    40 Posts

    Re: Number of site displays Link to this post

    what is "dev servers list" it's the first time I hear it

  • bartvanirsel
    Avatar
    Community Member
    94 Posts

    Re: Number of site displays Link to this post

    in _config.php

    Director::set_dev_servers(array(
       'localhost',
       '127.0.0.1',
       'yourserver.com'
    ));

  • sebastiankozub
    Avatar
    Community Member
    40 Posts

    Re: Number of site displays Link to this post

    listing is very long, please give me your IP and I add yours to give you the access. site is here http://87.207.57.202/boston/

    here you can see code

    class Page extends SiteTree {

       public static $db = array(
          'ShowInTopMenu' => 'Boolean',
          'ShowInLeftMenu' => 'Boolean',
          'ShowInLeftMenu2' => 'Boolean',
          'visits' => 'Int'
       );

       public static $has_one = array(
       );
       
       function getCMSFields()
       {
          $fields = parent::getCMSFields();
          
          $fields->addFieldToTab("Root.Behaviour", new CheckboxField("ShowInTopMenu", "Pokaż w menu górnym"));
          $fields->addFieldToTab("Root.Behaviour", new CheckboxField("ShowInLeftMenu", "Pokaż w menu lewym"));
          $fields->addFieldToTab("Root.Behaviour", new CheckboxField("ShowInLeftMenu2", "Pokaż w menu lewym 2"));
          
          return $fields;
       }

    }

    class Page_Controller extends ContentController
    {
       function topMenu()
       {
          $whereStatement = "ShowInTopMenu = 1";
          return DataObject::get("Page", $whereStatement);
       }
       
       function leftMenu()
       {
          $whereStatement = "ShowInLeftMenu = 1";
          return DataObject::get("Page", $whereStatement);
       }
       
       function leftMenu2()
       {
          $whereStatement = "ShowInLeftMenu2 = 1";
          return DataObject::get("Page", $whereStatement);
       }
       
       function totalVisits()
       {
          return DB::query("SELECT SUM(visits) FROM page_live")->value();
       }
       
       public static $allowed_actions = array(
       );

       public function init()
       {
          parent::init();

          Requirements::themedCSS('layout');
          Requirements::themedCSS('typography');
          Requirements::themedCSS('form');
          
          //if( ?? cookie or session variable doesn't exist ?? )
          //{
             //?? create session or cookie ??

             $this->visits++;
             $this->write();

          //}
       }
    }

    so the important is $this->visits++; in Page Controller and 'visits' => 'Int' in public static $db

  • sebastiankozub
    Avatar
    Community Member
    40 Posts

    Re: Number of site displays Link to this post

    there is no update query on visits in any page* table

    1863 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.