Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » 2.4 - DOM in SiteConfig not working for me

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3 4 5
Go to End
Author Topic: 6494 Views
  • Geo
    Avatar
    Community Member
    1 Post

    Re: 2.4 - DOM in SiteConfig not working for me Link to this post

    hi, i made a form, and its working fine, but i wana make a link to the full event and cant get it working,dont know whats wrong. my code:

    <div id="Content" class="typography">
    <h2>Current event information:</h2>
    <ul id="NewsList">
    <% if Children %>
    <% control EventResults %>
    <li>
    <div class="newsDateTitle"><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Event</a></div>
    <div class="newsDateTitle">Your email address: $Email </div>
    <div class="newsDateTitle">Where: $Area,$Country</div>
    <div class="newsDateTitle">When: $Date </div>
    <div class="newsSummary">What sector: $Sector</div>
    <div class="newsSummary">Description: $Description.FirstSentence</div>
    </li>
    <br/>
    <% end_control %>
    <% end_if %>
    </ul>
    </div>

    it makes the link but when you click it,it just goes to homepage, and doesnt display it. im new to silver stripe, and all the tut links is from cms where you putted it in, but this one from my db is giving me problems

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: 2.4 - DOM in SiteConfig not working for me Link to this post

    @UC - Did that work? Have you added it or does it need to be changed? Just wondering as it would be great not to have to make the changes for DOM in SiteConfig every time.

    @Geo - This is because your DataObjects are not pages so they can't be displayed like that. I wrote a tutorial a while back on how to display DO on a page, but unfortunately it requires a little extra work to get going on 2.4. Still have a look through as it will give you a basic understanding of what is going on and I did leave a comment which points in the direction of making it work in 2.4.

    I will be releasing a new Tut on doing this 'properly' in 2.4 when the NEW SSBits site launches soon ;)

    Aram

    www.ssbits.com - SilverStripe Tutorials, Tips and Other bits

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: 2.4 - DOM in SiteConfig not working for me Link to this post

    I just wanted to chime in and say that setSourceID can be used in other contexts since it can be used to add a DOM to a page that's linked to something else. Not a very common usecase perhaps but I've used setSourceID like that a couple of times and it works great. The difference to Arams code is that in my version I give $sourceID precedence in the sourceID() function since I'm figuring that if I actually go and set it myself manually then it's a special case and I specfically want that behaviour.

    So the difference in my version is that I check $this->sourceID first in the sourceID() function and return that if it's set, otherwise do the normal stuff.

  • UncleCheese
    Avatar
    4085 Posts

    Re: 2.4 - DOM in SiteConfig not working for me Link to this post

    Aram, that's all checked in. Thanks!

  • klikhier
    Avatar
    Community Member
    150 Posts

    Re: 2.4 - DOM in SiteConfig not working for me Link to this post

    I found that the example from SSbits doesnot work for an ImageDOM? This is the code I use. What changes are required to make this work?

    <?php
    class CustomSiteConfig extends DataObjectDecorator{

    function extraStatics() {
    return array(
    'db' => array(
    ),
    'has_many' => array(
          'SlideshowPhotos' => 'SlideshowPhoto'
    )
    );
    }

    public function updateCMSFields(FieldSet &$fields) {

    $idom = new SiteConfig_ImageDataObjectManager(
    $this->owner,
    'SlideshowPhotos',
    'SlideshowPhoto',
    'Image',
    array(),
    'getCMSFields_forPopup'
    );
    $idom->setSourceID($this->owner->ID);
    $fields->addFieldToTab("Root.Photos", $idom);

    }
    }

    class SiteConfig_ImageDataObjectManager extends ImageDataObjectManager {

    function setSourceID($val) {
    if (is_numeric($val)) {
    $this->sourceID = $val;
    }
    }

    function sourceID() {
    if (isset($this->sourceID) && $this->sourceID !== null && is_numeric($this->sourceID)) {
    return $this->sourceID;
    }
    return parent::sourceID();
    }

    }

    ?>

  • UncleCheese
    Avatar
    4085 Posts

    Re: 2.4 - DOM in SiteConfig not working for me Link to this post

    What does "doesn't work" mean?

  • klikhier
    Avatar
    Community Member
    150 Posts

    Re: 2.4 - DOM in SiteConfig not working for me Link to this post

    Sorry, should have mentioned that. Adding photo works fine, but when you click on that photo in image dom to get details the following error occurs:

    [User Error] Couldn't run query: SELECT "SlideshowPhoto"."ClassName", "SlideshowPhoto"."Created", "SlideshowPhoto"."LastEdited", "SlideshowPhoto"."Caption", "SlideshowPhoto"."ImageID", "SlideshowPhoto"."CustomSiteConfigID", "SlideshowPhoto"."ID", CASE WHEN "SlideshowPhoto"."ClassName" IS NOT NULL THEN "SlideshowPhoto"."ClassName" ELSE 'SlideshowPhoto' END AS "RecordClassName" FROM "SlideshowPhoto" WHERE ("ParentID" = '1') Unknown column 'ParentID' in 'where clause'
    GET /o-original.com/www/admin/EditForm/field/SlideshowPhotos/item/20/edit?ctf[SlideshowPhotos][start]=0&ctf[SlideshowPhotos][per_page]=10&ctf[SlideshowPhotos][showall]=0&ctf[SlideshowPhotos][sort]=Created&ctf[SlideshowPhotos][sort_dir]=DESC&ctf[SlideshowPhotos][search]=&ctf[SlideshowPhotos][filter]=&ctf[SlideshowPhotos][view]=grid&ctf[SlideshowPhotos][imagesize]=100

    Line 536 in /.../sapphire/core/model/MySQLDatabase.php

  • UncleCheese
    Avatar
    4085 Posts

    Re: 2.4 - DOM in SiteConfig not working for me Link to this post

    Don't forget to use setParentClass("SiteConfig");

    6494 Views
Page: 1 2 3 4 5
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.