Jump to:

5537 Posts in 1737 Topics by 1223 members

Customising the CMS

SilverStripe Forums » Customising the CMS » A Few Questions About Extending A Custom Image Type Across All Pages

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

Page: 1
Go to End
Author Topic: 343 Views
  • Tama
    Community Member
    130 Posts

    A Few Questions About Extending A Custom Image Type Across All Pages Link to this post

    This linked code creates a CustomImage type which has a Caption and Location added to the object: http://www.sspaste.com/paste/show/4ed419a088ff7

    I want to achieve a number of enhancements and outcomes with this code:

    1. When "Add An Image" is clicked in the CMS a window (getCMSFields_forPopup) appears and an image can be uploaded and caption added. When the new image has been saved, and the popup closed I want to have the image automatically added to the page.

    2. The Location value specifies where the image is displayed on a page. For example the Location "sidebar" would make the image appear in the sidebar or "below-article" would make the image appear below the article. I want to be able to specify the list of available locations so it relates to the Page type. For example a MapPage might have the locations "above-map" and "below-map" while NewsPage might have "top-right", "bottom-left" and "bottom-right". How do I specify the location options in the getCMSFields_forPopup so they can be set by each Page type?

    3. I'd like to make it so a Page can have many CustomImages but only one CustomImage can be "Featured". What is the best way of setting up and controlling this relationship?

    4. Currently all of the CustomImages are displayed in the CMS on every single page. Ideally I'd just like to display those CustomImages attached to the Page. If that isn't possible I'd like to sort the table with the attached images at the top.

    Thank you in advance.


  • martimiz
    Forum Moderator
    1078 Posts

    Re: A Few Questions About Extending A Custom Image Type Across All Pages Link to this post

    just off the top of my head - you could define a has_may relation from your Page to your SpecialImage, use a sortable listfield like the DataObjectManager, or ajshort's Orderable module.

    You could have a 'Location' array variable in your SpecialImage class that you could then set from your PageType's getCMSFunction, and use to display as a dropdown in your listfields popup.

    Then, since you are using a sortable listfield, the one on top could always be the featured one, so you can easily change it. (order by SortOrder, limit 1)

    Something like that?

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.