Better way to make make more contenttype fields

A forum for Bolt related questions / issues

Better way to make make more contenttype fields

Postby Logfather » Wed Aug 14, 2013 9:04 am

Hey guys,

I'm working on setting up all the necessary contenttypes for my switch to Bolt but I have a question about the best practice for multiple fields. In this case video.
Entries come with one field to add one video. But what if I want more?

Do I generate more fields (video2, video3, video4 etc.) or is there another way? And if I want 11 all of a sudden I just add another fied? That seems like a hassle. I'm considering a checkbox w/ switch so I can add fields when necessary because if I add room for say 10 videos to start of with it can get kinda cluttered.
Logfather
 
Posts: 163
Joined: Sun Jul 12, 2009 9:29 am
Location: Amsterdam

Re: Better way to make make more contenttype fields

Postby streeff » Thu Aug 15, 2013 10:12 am

The simplest way out would be letting editors put 10 videos in a wysiwyg field - but then I don't know what you want to achieve with your site.

Otherwise:
You could make a contenttype "myvideo" and put your clips there (and maybe some extra fields), one clip per "myvideo".

On the backend of the page put a text field in which editors put an array with the unique number(s) of the myvideo(s) that they want to show on that page, loop through the array in your template...
For me this is easier said than 'twigged' so I cannot give a code example right away.

Other suggestions coming in?
Evert Albers, Streeff - web // branding // information design - Amersfoort & Amsterdam, NL
Site: http://www.streeff.nl
User avatar
streeff
 
Posts: 146
Joined: Sat Jul 25, 2009 9:28 pm
Location: Amersfoort, NL

Re: Better way to make make more contenttype fields

Postby Logfather » Thu Aug 15, 2013 2:04 pm

Thanks those are good ideas for this.

The reason I want this is a possible video gallery and having the plain option of adding several (10 or less at least) vids. I can indeed make a text field to provide the unique YouTube ID that's entered into a hard coded embed code. Only thing I need to figure out now is how it will loop through that text field when more than one ID is provided (outcome should be: more videos).
Logfather
 
Posts: 163
Joined: Sun Jul 12, 2009 9:29 am
Location: Amsterdam

Re: Better way to make make more contenttype fields

Postby Bob » Wed Aug 21, 2013 3:04 pm

You could add a normal textarea (as in: not Wysiwyg) named videolist and just add youtube URL's one by one. like this:

Code: Select all
http://www.youtube.com/watch?v=VlFXuiEPD_k
http://www.youtube.com/watch?v=C4ft7sUK9jg


Then, in your template, split them, and create the videoplayers by hand in HTML with something like http://www.mediaelementjs.com

Code: Select all
{% for video record.videolist|split("\n") %}
<video width="640" height="360" id="player1" preload="none">
    <source type="video/youtube" src="video" />
</video>
{% endfor %}


Less user-friendly than adding a bunch of video-fields, but it might give you the control you want.
Bob
Lead Developer
 
Posts: 1374
Joined: Tue Nov 20, 2007 11:16 pm

Re: Better way to make make more contenttype fields

Postby Logfather » Tue Apr 08, 2014 9:36 pm

Got pretty far with this:

Code: Select all
{% if "youtu.be" in record.video1.url %}
<div class="video-container">
<iframe src="//{{ record.video1.url }}></iframe>       
</div>
{% endif %}


Something I haven't been able to figure out: when I throw a {{ record.video1.url }} in the content, I need it to be replaced by the above code obviously (in order to full control). Is this where I have to write a custom function in a separate bundle in order to make it work? Throwing the code in my template works of course but then the location of the video is hard-coded in the template.
Logfather
 
Posts: 163
Joined: Sun Jul 12, 2009 9:29 am
Location: Amsterdam


Return to Bolt Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron