Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

756 Posts in 191 Topics by 245 members

Blog Module

SilverStripe Forums » Blog Module » Add dataobject manager images through frontend

Discuss the Blog Module.

Page: 1
Go to End
Author Topic: Add dataobject manager images through frontend 911 Views
  • klikhier
    avatar
    Community Member
    66 posts

    Add dataobject manager images through frontend Link to this post

    Hello, I have set up an ImageDateObjectManager that allows for adding multiple images to a BlogEntry through the CMS. My question: is it possible to add ONE image via www.website.com/blog/post?

    Of course I can add the code below to function BlogEntryForm() in BlogHolder.php...

    new SimpleImageField('Image', 'Image (optional)'),

    ..but is it possible to use such a solution to add one photo through the frontend (myUrl/blog/post) that will be visible in the ImageDataObjectManager in the CMS?

  • UncleCheese
    avatar
    Forum Moderator
    2667 posts

    Re: Add dataobject manager images through frontend Link to this post

    Well before you go hacking the core code, I would create a BlogHolder subclass so you can safely overload the BlogEntryForm() function. What was the result when you added an image field to that? I think it may work fine, because the postblog() handler just runs $form->saveInto(), and I believe that takes into account your related objects and uploads. If not, just overload the postblog() function.

  • klikhier
    avatar
    Community Member
    66 posts

    Re: Add dataobject manager images through frontend Link to this post

    Thanks UncleCheese, I started with SS as a designer, so forgive me my coding shortcuts (and the overloading) What I have right now:

    Photo.php

    class Photo extends DataObject
    {
       static $db = array (
    'Caption' => 'Text'
       );

       static $has_one = array (
    'Image' => 'Image',
          'Page' => 'Page',
          'GalleryPage' => 'GalleryPage',
          'CalculatorPage' => 'CalculatorPage',
          'BlogHolder' => 'BlogHolder',
          'BlogEntry' => 'BlogEntry'
       );
       
       public function getCMSFields_forPopup()
       {
          return new FieldSet(
    new TextField('Caption','Name'),
             new ImageField('Image')
          );
       }

    }

    $has_many in BlogEntry.php

       static $has_many = array(
    'Photos' => 'Photo'
       );

    Added to function BlogEntryForm() in BlogHolder.php

             
    new SimpleImageField('Photos', 'Image (optional)'),

    This doesn't work? I don't fully understand what you mean with your latest sentence, so if you could... please help once more. Many thanks in advance!

    911 Views
Page: 1
Go to Top

Currently Online: jseth

Welcome to our latest member: holy noli

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

Comments on this website? Please give feedback.