Custom block, multiple files
Permalink
Hi everyone,
I'm like to build a block that sounds simple, but looks difficult to me...
the layout will be quite simple: one or more images on the left, a title and a (rich)text on the right.
I found several tutorials around but couldn't find a full example.
I found this one:
http://www.concrete5.org/index.php?cID=45665...
The file selection works in add part (don't know if the described method is good), but I can't find how to store them in db.
Can't find either how to add a (customized) rich text editor, so editors can add bold, links, subtitles, in text zone for example.
Maybe i'm asking a lot, but i'm really not an expert in php / c5.
Thanks for your help !!
I'm like to build a block that sounds simple, but looks difficult to me...
the layout will be quite simple: one or more images on the left, a title and a (rich)text on the right.
I found several tutorials around but couldn't find a full example.
I found this one:
http://www.concrete5.org/index.php?cID=45665...
The file selection works in add part (don't know if the described method is good), but I can't find how to store them in db.
Can't find either how to add a (customized) rich text editor, so editors can add bold, links, subtitles, in text zone for example.
Maybe i'm asking a lot, but i'm really not an expert in php / c5.
Thanks for your help !!
Thanks for the tip, it simplifies greatly custom block creation.
But, unless i'm wrong, it doesn't allow multiple images selection.
The only way I found is to add many not mandatory image fields when creating a block (let's say 10), and hope that more images won't be necessary.
Am I missing something ?
But, unless i'm wrong, it doesn't allow multiple images selection.
The only way I found is to add many not mandatory image fields when creating a block (let's say 10), and hope that more images won't be necessary.
Am I missing something ?
I am sure Jordan will chip in if I am wrong, but I think what you have described is the case.
As an alternative, rather than one block, allow your editors access to add, edit and approve a designer content created block that ties down the format to 1 bit of text and 1 pic. They can then add a new block per pic.
As an alternative, rather than one block, allow your editors access to add, edit and approve a designer content created block that ties down the format to 1 bit of text and 1 pic. They can then add a new block per pic.
Yes, or maybe creating 1 block for most cases (3 pics),
and another one for more pics (limited to 10-15 to keep a consistent layout).
If the author or someone goes through here and has a better idea, please don't hesitate!
And thanks again for the Designer Content, it helps a lot.
and another one for more pics (limited to 10-15 to keep a consistent layout).
If the author or someone goes through here and has a better idea, please don't hesitate!
And thanks again for the Designer Content, it helps a lot.
Howdy, Designer Content author here.
I agree with all of John's advice above. Designer content wasn't meant to be used with file sets -- only single pieces of content (so one or two images really -- you can add 10 fields but it's a very clunky interface).
It sounds like what you want to add is a file set selection. This can get a bit tricky, but I have some boilerplate code for an image gallery/slideshow block that you might find useful:
https://github.com/jordanlev/c5_designer_gallery...
You'll have to pick it apart and integrate the file set selection stuff with your existing custom block -- will definitely require a bit of work to do.
Good luck!
I agree with all of John's advice above. Designer content wasn't meant to be used with file sets -- only single pieces of content (so one or two images really -- you can add 10 fields but it's a very clunky interface).
It sounds like what you want to add is a file set selection. This can get a bit tricky, but I have some boilerplate code for an image gallery/slideshow block that you might find useful:
https://github.com/jordanlev/c5_designer_gallery...
You'll have to pick it apart and integrate the file set selection stuff with your existing custom block -- will definitely require a bit of work to do.
Good luck!
Thanks author!
I'm afraid this last solution is a bit beyond my abilities...
What I did (for now) is actually adding 10 images in the block.
And with 2 lines of jQuery I hide the unused ones, and with a little "add more" button, I show a new field.
Probably not the nicest solution ever, but it works, and keeps the interface clean.
I'm afraid this last solution is a bit beyond my abilities...
What I did (for now) is actually adding 10 images in the block.
And with 2 lines of jQuery I hide the unused ones, and with a little "add more" button, I show a new field.
Probably not the nicest solution ever, but it works, and keeps the interface clean.
As long as you don't need more than 10 images, I actually think your solution is brilliant -- easy, clean and simple.
Then i'll share, but you'll probably have to customize it, and even make it better, I'm not sure my code is the best solution.
In your edit.php :
- Add a class on all your image entries. By default, they'll have .ccm-block-field-group. Let's say we add .imageEntry
- Then add this, below the last one :
<a href="#" id="moreImg"><?php echo ('Add More')?></a>
<script>
var numImg=1;
$(".imageEntry:gt(1)").hide(); //hiding only from the second one, keeping the first one displayed.
$("#moreImg").click(function() {
$(".imageEntry):eq("+numImg+")").show();
numImg++;
});
</script>
In your edit.php :
- Add a class on all your image entries. By default, they'll have .ccm-block-field-group. Let's say we add .imageEntry
- Then add this, below the last one :
<a href="#" id="moreImg"><?php echo ('Add More')?></a>
<script>
var numImg=1;
$(".imageEntry:gt(1)").hide(); //hiding only from the second one, keeping the first one displayed.
$("#moreImg").click(function() {
$(".imageEntry):eq("+numImg+")").show();
numImg++;
});
</script>
http://www.concrete5.org/marketplace/addons/designer-content/...