Jump to:

21301 Posts in 5736 Topics by 2603 members

General Questions

SilverStripe Forums » General Questions » SS3 DataExtension + Data Object

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

Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 909 Views
  • Craftnet
    Avatar
    Community Member
    46 Posts

    SS3 DataExtension + Data Object Link to this post

    Hi,

    I have problem.

    Generally I want in one place add pictures to the sliders and they are to be displayed on all pages.

    In SS 2.4.7 I add to SiteConfig
    In SS3 I would do the same so:

    I try add to DataExtension DataObject

    AllSite.php

    class AllSite extends DataExtension {
       
       static $has_many = array (
    'Sliders' => 'Slider'
    );
       
       public function updateCMSFields(FieldList $fields) {
       
       
        //SLIDER
          $gridFieldConfigSlider = GridFieldConfig::create()->addComponents(
             new GridFieldToolbarHeader(''),
    new GridFieldAddNewButton('toolbar-header-right'),
             new GridFieldDataColumns(),
             new GridFieldEditButton(),
             new GridFieldDeleteAction(''),
             new GridFieldDetailForm()
          );
          
          $gridFieldSlider = new GridField('Sliders', 'Slider', new DataList('Slider'), $gridFieldConfigSlider);
          $fields->addFieldToTab('Root.Slider', $gridFieldSlider);

    }    
    }

    class Slider extends DataObject
    {
    static $db = array (

    );

    static $has_one = array (
    'Slider' => 'Image',

    );
       
       function getCMSFields() {
    return new FieldSet(
    new UploadField('Slider')
    );
    }
    }

    in template i add:

    <% loop SiteConfig %>
       $Slider
    <% end_loop %>

    inn backend i can add image to slider but in frontend in right place picture not show

    Who have any idea?

    Sorry for my bad English

  • martimiz
    Avatar
    Forum Moderator
    876 Posts

    Re: SS3 DataExtension + Data Object Link to this post

    Maybe something like:

    <% with SiteConfig %>
       <% loop $Sliders %>
          $Slider
       <% end_loop %>
    <% end_with %>

  • Craftnet
    Avatar
    Community Member
    46 Posts

    Re: SS3 DataExtension + Data Object Link to this post

    thx for replay.

    still nothing,
    In you'r set i have errorp (you have to remove the $ in the control)
    . I'm not sure if the code is correct, but even that everything looks good

    If for example I will add to the database
    static $ db = array (
             'FooterContent' => 'htmlText'
         );

    then <% control SiteConfig%> work but not in my example.

    In last resort, write a function that collects in Page_Controller in someone side of these figures but I'd also know such a solution.

    Sorry for my bad english

  • martimiz
    Avatar
    Forum Moderator
    876 Posts

    Re: SS3 DataExtension + Data Object Link to this post

    Sorry about the &

    Does your Slide object link back to SiteConfig, using something like:

    static $has_one = array('SiteConfig' => 'SiteConfig');

    i've not yet used the GridField from the SiteConfig, so I don't know if it works at all...
    You could try a ?showqueries=1 to check if the query on Slides is actually executed and what it looks like...

    909 Views
Page: 1
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.