Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » IF conditions in DataObjectManager

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 781 Views
  • snaip
    Avatar
    Community Member
    180 Posts

    IF conditions in DataObjectManager Link to this post

    Hi

    I'm using DataObjectManager with SimpleTreeDropDownField to select Pages

    <?php
    class ModulBoxy extends DataObject {
       static $db = array (
    'Nazwa' => 'Varchar'
       );
       
       static $has_one = array (
          'Strona' => 'Strona',
          'Page' => 'SiteTree'
       );
       
       public function getCMSFields_forPopup()   {
          return new FieldSet(
    new TextField('Nazwa','Nazwa:'),
             new SimpleTreeDropdownField('PageID', 'Select Page:', 'SiteTree')
          );
       }
    }
    ?>

    Strona.php

    public static $has_many = array(
    'ModulBoxy' => 'ModulBoxy'
    );

       function getCMSFields() {
          $fields = parent::getCMSFields();

          $manager_boxy = new DataObjectManager(
             $this,
             'ModulBoxy',
             'ModulBoxy',
             array(
                'Nazwa' => 'Nazwa',
    'PageID' => 'Page'
             ),
             'getCMSFields_forPopup'
          );

    $fields->addFieldToTab("Root.Content.BoczneBoxy",$manager_boxy);

    return $fields;
    }

    In Templete i get the values like:

    Stona.ss

    <% control ModulBoxy %>
    $Page.Title
    <% end_control %>

    but if i want to do an IF condition the site is braking down

    <% if Page.ClassName == Faq %>
    do A function
    <% end_if %>

    it is so strange, in the next steps i have to do this

    <% if Page.ClassName == Faq %>
    <% include BoxFaq %>
    <% end_if %>

    <% if Page.ClassName == Contact %>
    <% include BoxContact %>
    <% end_if %>

    BoxFaq.ss

    <% control ModulFaq %> // another DataObjectManager with ImageGallery
    $Title

    <% control Attachment %>
    %Title
    <% end_control %>

    <% end_control %>

  • UncleCheese
    Avatar
    4085 Posts

    Re: IF conditions in DataObjectManager Link to this post

    I'm not really seeing the issue??

    --------------------
    SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

  • snaip
    Avatar
    Community Member
    180 Posts

    Re: IF conditions in DataObjectManager Link to this post

    i get blank page
    try it yourself, maybe i'm doing something wrong

  • UncleCheese
    Avatar
    4085 Posts

    Re: IF conditions in DataObjectManager Link to this post

    Turn on your PHP error reporting. A blank page isn't very helpful!

    --------------------
    SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

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