Jump to:

5513 Posts in 1732 Topics by 1218 members

Customising the CMS

SilverStripe Forums » Customising the CMS » ImageField throwing page not found error

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

Page: 1
Go to End
Author Topic: 1169 Views
  • Sherry
    Avatar
    Community Member
    4 Posts

    ImageField throwing page not found error Link to this post

    I have launched about 5 or 6 SilverStripe installations, many of which use the imagefield following the example in tutorial 2: http://doc.silverstripe.org/tutorial:2-extending-a-basic-site. The sites I've launched using SS v2.3.x work fine, but with the last 2 sites, which use v2.4.1 the imagefields are not working for me.

    I've tried several variations of code and all yield the same result in 2.4.1: The image field displays a page not found page using whatever template is set for the site. Specifically, the error is: Sorry, it seems you were trying to access a page that doesn't exist. Please check the spelling of the URL you were trying to access and try again.

    I have had no luck determining the difference between my v2.3 sites where the image field works as expected and the v2.4.1 sites where it doesn't. Any assistance is appreciated.

    The latest rendition of the code is:

    <?php
    class SalonPage extends Page {

       public static $db = array(
       );

    static $has_one = array(
    'Photo' => 'Image'
    );

    function getCMSFields() {
        $fields = parent::getCMSFields();
        $picField = new ImageField('Photo');
        $fields->addFieldToTab("Root.Content.Images", $picField);      
       
        return $fields;
    }

    }
    class SalonPage_Controller extends Page_Controller {

       public function init() {
          parent::init();
       }
    }
    ?>

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: ImageField throwing page not found error Link to this post

    For a Page (public facing) I believe the only route is something like this...

    $fields->replaceField('Photo',new SimpleImageField('Photo'));

    but within the CMS I don't ever need to do anything in order to get my images to appear as I use ModelAdmin and the scaffolding works just fine.

    Sorry I can't be more help...

  • Sherry
    Avatar
    Community Member
    4 Posts

    Re: ImageField throwing page not found error Link to this post

    Thanks for the reply. Unfortunately, that code variation threw the same error.

    I've added a work around that just creates another HTMLEditorField and the image is added there:
    static $db = array(
          'PageTitlePic' => 'HTMLText'
    );

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

    $fields->addFieldToTab("Root.Content.Main", new HTMLEditorField('PageTitlePic', 'Page Title'),'Content');

    return $fields;
    }

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