Jump to:

23483 Posts in 18976 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Only show 6 records

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: 1112 Views
  • alex123
    Avatar
    Community Member
    18 Posts

    Re: Only show 6 records Link to this post

    Hihi,

    I already see it and I change the code It works ok. I limit 6 records.

    $limit = "{$_GET['start']},50"

    But If I keep 6 records

    $limit = "{$_GET['start']},6" -> If the database more than 6 records It will show pagination page. Do I need config somewhere to showing pagination page

    I got another problem. It doesn't load image from my store on admin. Can you look my attach file

    Attached Files
  • alex123
    Avatar
    Community Member
    18 Posts

    Re: Only show 6 records Link to this post

    yes I already fix it thanks you a lot. Can you look it another issue. It doesn't load image from my store .

  • IOTI
    Avatar
    Community Member
    189 Posts

    Re: Only show 6 records Link to this post

    Hey Alex,

    Awesome to see you found the code! Nice job fixing that part.

    As for the image, you'll want to update the code used for adding the image field to the CMS. So in your function "getCMSFields()" there is probably something that looks like

    $fields->addFieldToTab('Root.Content.Slides', new ImageField('Image",'Image'));

    you'll want to update the "new ImageField()" part to use UploadField instead like so

    $fields->addFieldToTab('Root.Content.Slides', new UploadField('Image",'Image'));

  • alex123
    Avatar
    Community Member
    18 Posts

    Re: Only show 6 records Link to this post

    can you send to me the name of file which I change this code ?

  • alex123
    Avatar
    Community Member
    18 Posts

    Re: Only show 6 records Link to this post

    Is It GenericPage.php page ?

  • IOTI
    Avatar
    Community Member
    189 Posts

    Re: Only show 6 records Link to this post

    I don't know what file it would be Alex, sorry. You should update anywheres it says "ImageField" to "UploadField" when using SilverStripe v3.

  • alex123
    Avatar
    Community Member
    18 Posts

    Re: Only show 6 records Link to this post

    on mysite/homepage.php

    $fields->addFieldToTab("Root.Content.Slides", new SimpleImageField('SlideImage2', 'Image'));

    I change to

    $fields->addFieldToTab("Root.Content.Slides", new SimpleUploadField('SlideImage2', 'Image'));

    But it doesn't work

  • alex123
    Avatar
    Community Member
    18 Posts

    Re: Only show 6 records Link to this post

    this is a code of homepage.php Because silder on homepage

    <?php

    /**
    * Defines the homePage page type
    */

    class homePage extends SiteTree {
       static $allowed_children = "none";
       
       static $db = array(
          'Address' => 'HTMLText',
          'SlideDescriptionShort1' => 'Text',
          'SlideDescriptionLong1' => 'Text',
          'SlideDescriptionShort2' => 'Text',
          'SlideDescriptionLong2' => 'Text',
          'SlideDescriptionShort3' => 'Text',
          'SlideDescriptionLong3' => 'Text',
          'SlideDescriptionShort4' => 'Text',
          'SlideDescriptionLong4' => 'Text',
          'SlideDescriptionShort5' => 'Text',
          'SlideDescriptionLong5' => 'Text',
          'SlideDescriptionShort6' => 'Text',
          'SlideDescriptionLong6' => 'Text',
          'SlideDescriptionShort7' => 'Text',
          'SlideDescriptionLong7' => 'Text',
          'SlideDescriptionShort8' => 'Text',
          'SlideDescriptionLong8' => 'Text',
          'DomesticTitle' => 'Text',
          'DomesticTagline' => 'Text',
          'ProfessonialTitle' => 'Text',
          'ProfessonialTagline' => 'Text',
          'NewPanelTitle' => 'Text',
          'NewPanelTagline' => 'Text',
          'NewProductTitle' => 'Text',
          'NewProductTagline' => 'Text',            
          'OurProductTitle' => 'Text',
          'OurProductTagline' => 'Text',            
          'PublicationsTitle' => 'Text',
          'PublicationsTagline' => 'Text',            
       );
       static $has_many = array(
          'UsedBy' => 'Sponsor'
       );
       public static $has_one = array(
          'SlideImage1' => 'Image',
          'SlideImage2' => 'Image',
          'SlideImage3' => 'Image',
          'SlideImage4' => 'Image',
          'SlideImage5' => 'Image',
          'SlideImage6' => 'Image',
          'SlideImage7' => 'Image',
          'SlideImage8' => 'Image',
          'SlidePage1' => 'SiteTree',
          'SlidePage2' => 'SiteTree',
          'SlidePage3' => 'SiteTree',
          'SlidePage4' => 'SiteTree',
          'SlidePage5' => 'SiteTree',
          'SlidePage6' => 'SiteTree',
          'SlidePage7' => 'SiteTree',
          'SlidePage8' => 'SiteTree',
          'DomesticLink' => 'SiteTree',
          'DomesticImage' => 'Image',
          'ProfessonialLink' => 'SiteTree',
          'ProfessonialImage' => 'Image',
          'NewPanelLink' => 'SiteTree',
          'NewPanelImage' => 'Image',
          'NewProductLink' => 'SiteTree',
          'NewProductImage' => 'Image',
          'OurProductLink' => 'SiteTree',
          'OurProductImage' => 'Image',      
          'PublicationsLink' => 'SiteTree',
          'PublicationsImage' => 'Image',
       );
       
       function getCMSFields() {
    $fields = parent::getCMSFields();
       
          // add field to edit footer and address section

    $fields->addFieldToTab("Root.Content.Address", new HTMLEditorField('Address', 'Address'));

    // Slides
          // Slide 1
       $fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h2>Left Slide Window</h2>"));
    $fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4>Slide 1</h4>"));
    $fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort1', 'Short description'));
    $fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong1', 'Long description'));
    $fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage1ID', 'Page', 'SiteTree'));
    // $fields->addFieldToTab("Root.Content.Slides", new UploadField('Image', 'Image'));
       $fields->addFieldToTab("Root.Content.Slides", new SimpleUploadField('SlideImage1', 'Image'));
          // Slide 2
    $fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 2</h4>"));
    $fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort2', 'Short description'));
    $fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong2', 'Long description'));
    $fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage2ID', 'Page', 'SiteTree'));
    $fields->addFieldToTab("Root.Content.Slides", new SimpleImageField('SlideImage2', 'Image'));
          // Slide 3
    $fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 3</h4>"));
    $fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort3', 'Short description'));
    $fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong3', 'Long description'));
    $fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage3ID', 'Page', 'SiteTree'));
    $fields->addFieldToTab("Root.Content.Slides", new SimpleImageField('SlideImage3', 'Image'));
          // Slide 4
    $fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 4</h4>"));
    $fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort4', 'Short description'));
    $fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong4', 'Long description'));
    $fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage4ID', 'Page', 'SiteTree'));      
    $fields->addFieldToTab("Root.Content.Slides", new SimpleImageField('SlideImage4', 'Image'));

       $fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h2>Right Slide Window</h2>"));
          // Slide 5
    $fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4>Slide 1</h4>"));
    $fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort5', 'Short description'));
    $fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong5', 'Long description'));
    $fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage5ID', 'Page', 'SiteTree'));
    $fields->addFieldToTab("Root.Content.Slides", new SimpleImageField('SlideImage5', 'Image'));
          // Slide 6
    $fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 2</h4>"));
    $fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort6', 'Short description'));
    $fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong6', 'Long description'));
    $fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage6ID', 'Page', 'SiteTree'));
    $fields->addFieldToTab("Root.Content.Slides", new SimpleImageField('SlideImage6', 'Image'));

    // Slide 7
    $fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 3</h4>"));
    $fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort7', 'Short description'));
    $fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong7', 'Long description'));
    $fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage7ID', 'Page', 'SiteTree'));
    $fields->addFieldToTab("Root.Content.Slides", new SimpleImageField('SlideImage7', 'Image'));

    // Slide 8
    $fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 4</h4>"));
    $fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort8', 'Short description'));
    $fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong8', 'Long description'));
    $fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage8ID', 'Page', 'SiteTree'));
    $fields->addFieldToTab("Root.Content.Slides", new SimpleImageField('SlideImage8', 'Image'));

       $tablefield = new HasManyComplexTableField(
                   $this,
                   'UsedBy',
                   'Sponsor',
                   array( 'Thumbnail' => 'Image', 'CompanyName' => 'Company Name'),
                   'getCMSFields_forPopup'
                   );
       $tablefield->setAddTitle( 'A Product User' );

    //   $fields->addFieldToTab( 'Root.Content.ProductUser', $tablefield );

       $fields->addFieldToTab('Root.Content.NewsletterPanels', new LiteralField ("literalfield", "<h3>Domestic Newsletter Panel</h3>"));
    $fields->addFieldToTab('Root.Content.NewsletterPanels', new TextField('DomesticTitle', 'Domestic Title'));
    $fields->addFieldToTab('Root.Content.NewsletterPanels', new TextField('DomesticTagline', 'Domestic Tagline'));
    $fields->addFieldToTab('Root.Content.NewsletterPanels', new TreeDropdownField('DomesticLinkID', 'Domestic Link', 'SiteTree'));
    $fields->addFieldToTab("Root.Content.NewsletterPanels", new SimpleImageField('DomesticImage', 'Domestic Image'));

       $fields->addFieldToTab('Root.Content.NewsletterPanels', new LiteralField ("literalfield", "<h3>Professional Newsletter Panel</h3>"));
    $fields->addFieldToTab('Root.Content.NewsletterPanels', new TextField('ProfessonialTitle', 'Professional Title'));
    $fields->addFieldToTab('Root.Content.NewsletterPanels', new TextField('ProfessonialTagline', 'Professional Tagline'));
    $fields->addFieldToTab('Root.Content.NewsletterPanels', new TreeDropdownField('ProfessonialLinkID', 'Professional Link', 'SiteTree'));
    $fields->addFieldToTab("Root.Content.NewsletterPanels", new SimpleImageField('ProfessonialImage', 'Professional Image'));

       $fields->addFieldToTab('Root.ProductsPanels', new LiteralField ("literalfield", "<h3>New Newsletter Panel</h3>"));
    $fields->addFieldToTab('Root.ProductsPanels', new TextField('NewPanelTitle', 'New Panel Title'));
    $fields->addFieldToTab('Root.ProductsPanels', new TextField('NewPanelTagline', 'New Panel Tagline'));
    $fields->addFieldToTab('Root.ProductsPanels', new TreeDropdownField('NewPanelLinkID', 'New Panel Link', 'SiteTree'));
    $fields->addFieldToTab("Root.ProductsPanels", new SimpleImageField('NewPanelImage', 'New Panel Image'));

       $fields->addFieldToTab('Root.ProductsPanels', new LiteralField ("literalfield", "<h3>New Product Panel</h3>"));
    $fields->addFieldToTab('Root.ProductsPanels', new TextField('NewProductTitle', 'New Product Title'));
    $fields->addFieldToTab('Root.ProductsPanels', new TextField('NewProductTagline', 'New Product Tagline'));
    $fields->addFieldToTab('Root.ProductsPanels', new TreeDropdownField('NewProductLinkID', 'New Product Link', 'SiteTree'));
    $fields->addFieldToTab("Root.ProductsPanels", new SimpleImageField('NewProductImage', 'New Product Image'));

       $fields->addFieldToTab('Root.ProductsPanels', new LiteralField ("literalfield", "<h3>Our Products Panel</h3>"));
    $fields->addFieldToTab('Root.ProductsPanels', new TextField('OurProductTitle', 'Our Product Title'));
    $fields->addFieldToTab('Root.ProductsPanels', new TextField('OurProductTagline', 'Our Product Tagline'));
    $fields->addFieldToTab('Root.ProductsPanels', new TreeDropdownField('OurProductLinkID', 'Our Product Link', 'SiteTree'));
    $fields->addFieldToTab("Root.ProductsPanels", new SimpleImageField('OurProductImage', 'Our Product Image'));

       $fields->addFieldToTab('Root.Content.PublicationsPanel', new LiteralField ("literalfield", "<h3>Publications Panel</h3>"));
    $fields->addFieldToTab('Root.Content.PublicationsPanel', new TextField('PublicationsTitle', 'Publications Title'));
    $fields->addFieldToTab('Root.Content.PublicationsPanel', new TextField('PublicationsTagline', 'Publications Tagline'));
    $fields->addFieldToTab('Root.Content.PublicationsPanel', new TreeDropdownField('PublicationsLinkID', 'Publications Link', 'SiteTree'));
    $fields->addFieldToTab("Root.Content.PublicationsPanel", new SimpleImageField('PublicationsImage', 'Publications Image'));

    return $fields;

    }
          function LeftFeatureImage($width=30, $height=30) {
           $Image = $this->SlideImage1();
           if ( $Image ) {
              if($Image->getWidth() > $width) {
                 return $Image->CroppedImage($width, $height);
              } else {
              return $Image;
              }
           } else {
           return null;
           }
          }
          function RightFeatureImage($width=30, $height=30) {
           $Image = $this->SlideImage5();
           if ( $Image ) {
              if($Image->getWidth() > $width) {
                 return $Image->CroppedImage($width, $height);
              } else {
              return $Image;
              }
           } else {
           return null;
           }
          }
        function LightBox()
           {
              if (isset($_COOKIE['Lightbox']))
                $cookie = 'none';
             else
              $cookie = 'block';
                
             return $cookie;   
           }         
    }

    class homePage_Controller extends Page_Controller {
       // Latest News
       function LatestNews($num=3) {
       $news = DataObject::get_one("NewsPageHolder");
          return ($news) ? DataObject::get("NewsPage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
       }

       // Latest Events
       function ComingEvents($num=3) {
       $event = DataObject::get_one("EventPageHolder");
       $yesterday = date('Y-m-d',mktime(0,0,0,date('m'), date('d')-1, date('Y')));
          return ($event) ? DataObject::get("EventPage", "`ParentID` = '".$event->ID."' and Date > '{$yesterday}'", "Date DESC", "", $num) : false;
       }

    }

    ?>

    1112 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.