Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Adding unlimited items to a page


Go to End


3 Posts   777 Views

Avatar
Bagzli

Community Member, 71 Posts

12 July 2014 at 1:56pm

Hello,

I was wondering how can I set up so that you can create unlimited items on the page. For example, I want to give the user to add as many images to the page as they want, and then for each image, I want them to be able to enter as many lines of text as they want that will go next to the image. Each line of text will be a new <p>. My issue is I do not know how to achieve the unlimited part with silverstripe, I don't want them adding a new page every time they want an item, there must be a better way.

Avatar
Fred Condo

Community Member, 29 Posts

13 July 2014 at 5:00am

The key is to make a has_many relationship between Page and Image. Image is supposed to have a Content field, but for some reason that is not exposed in the CMS. My colleagues have come up with an ImageAttachment data object to provide the additional fields. See this gist: https://gist.github.com/oddnoc/fd30108287db7ac32b00

Avatar
Bagzli

Community Member, 71 Posts

13 July 2014 at 10:09am

Thank you for the reply, I will try this sometimes this week when I have more free time! Thanks again!