ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

User-submitted galleries via front end form

November 26, 2012 6:10am

Subscribe [2]
  • #1 / Nov 26, 2012 6:10am

    Hello people! I’m trying to set up a form on the front end of a site for user-submitted image galleries. Obviously hidden by default, then set to ‘visible’ by admin if they’re OK. I’m new to EE and not really sure where to start. Any recommendations?

  • #2 / Nov 26, 2012 6:23am

    John St-Amand

    865 posts

    I’ve done something similar overall.  You should be able to use Safecracker for the front end submission and within that, perhaps use Matrix for flexible image submissions with the single posting. Just use statuses to control visibility (add a custom status of “pending” or something and likely add an entry notification preference on the channel you have the entries post to so that the admin gets an email when new galleries are posted).

  • #3 / Nov 26, 2012 6:26am

    Thanks John! A friend has just recommended using SafeCracker with Channel Images, is that pretty much the same thing? User would need to give a title and description for the gallery, then same again for each image, plus some other fields per image (date, location etc). Would the standard ‘closed’ status work or is a custom status necessary?

  • #4 / Nov 26, 2012 6:34am

    John St-Amand

    865 posts

    You could used closed status, but I’m generally more a fan of having a purpose-driven status rather than just use the two defaults, which have their own “roles” to play. If you use closed, those galleries would be mixed in with any other entry marked closed, which may be for a completely different reason.

    You COULD use Channel Images (I’m making the assumption here that’s it’s compatible with Safecracker - I have no idea whether it is or not), but if you start getting into the need for additional custom fields per image, it may be a bit more challenging, as i’m not sure if you can define additional custom fields per image in Channel Images.  So that might mean you would have to use existing fields per image and repurposed them (and whether you can change the labels for each is another issue).  So depending on how custom you need the additional fields per image to be would be a determining factor.

    With Matrix, it’s completely flexible. Each column you set up is a field per image, and you can define them as you please.

  • #5 / Nov 26, 2012 6:42am

    Thanks John - really appreciate the advice! I’m going to give this a shot and will post back results.

  • #6 / Nov 26, 2012 9:36am

    OK I’ve installed Matrix and ED Imageresizer according to https://pixelandtonic.com/matrix/docs/image-galleries. I’ve followed the instructions on that page down to the bottom, but now, visiting /galleries gives:

    Fatal error: Allowed memory size of 37748736 bytes exhausted (tried to allocate 8544 bytes) in /var/sites/b/bexon.scsmarketing.net/public_html/systematicee/expressionengine/third_party/ed_imageresizer/pi.ed_imageresizer.php on line 325

    Do I need to edit something on the line it refers to?

  • #7 / Nov 26, 2012 11:23am

    Don’t worry - I edited the ED file itself (the plugin file) and it’s working (albeit pretty damned slowly!). I’ll get the gallery working right, then I’ll look at front-end access to it.

  • #8 / Nov 27, 2012 6:17am

    OK gallery is working nicely with Matrix (I’m just using EE resizing rather than the ED thing) but complication with the SafeCracker form.

    The form needs to submit to the gallery channel, which contains description, uploader’s email, uploader’s phone number and ‘gallery’ (Matrix field). It also needs to fill the ‘gallery’ Matrix field’s title field, image (file) field, image title field, caption field, uploader’s name, uploader’s company and location photo was taken. I’m leaving file field for the time being until the rest is working.

    {embed='includes/header'}
    <h1>Welcome and lets get started!</h1>
    
    <hr >
    
    <strong>Here at Bexon we like to get to know you and your project…</strong>
    <div class="add-gallery-form">
    {exp:safecracker channel="galleries" return="/add-gallery"}
     <label>Gallery title:</label>
     <input name="gallery" class="input" type="text"><br >
     <label>Gallery description:</label>
     <input name="gallery_description" class="input" type="text"><br >
     <label>Image title:</label>
     <input name="image_title" class="input" type="text"><br >
     <label>Image description:</label>
     <input name="image_caption" class="input" type="text"><br >
     <label>Location:</label>
     <input name="location" class="input" type="text"><br >
     <label>Your name:</label>
     <input name="uploader_name" class="input" type="text"><br >
     <label>Company:</label>
     <input name="uploader_company" class="input" type="text"><br >
     <label>Email:</label>
     <input name="uploader_email" class="input" type="text"><br >
     <label>Telephone:</label>
     <input name="uploader_telephone" class="input" type="text"><br >
     <input type="submit" value="Submit" />
    {/exp:safecracker}
    </div><!-- .add-gallery-form -->
    {embed='includes/footer'}

    Results in:

    A PHP Error was encountered
    Severity: Warning
    Message: Invalid argument supplied for foreach()
    Filename: matrix/ft.matrix.php
    Line Number: 1997

    The form you submitted contained the following errors
    The Title field is required.
    Return to Previous Page

    I’d really appreciate any guidance on where I’m going wrong!

  • #9 / Nov 27, 2012 10:51am

    Anyone coming across this now, don’t worry - it’s still broken but I’m working through it with the Matrix support guys. Hopefully almost there 😊

  • #10 / Nov 27, 2012 11:12am

    OK here we go, working solution:

    {exp:safecracker channel="galleries" return="/add-gallery"}
    {field:gallery}
     <label>Gallery title:</label>
     <input name="title" class="input" type="text"><br >
     <label>Gallery description:</label>
     <input name="gallery_description" class="input" type="text"><br >
     <label>Email:</label>
     <input name="uploader_email" class="input" type="text"><br >
     <label>Telephone:</label>
     <input name="uploader_telephone" class="input" type="text"><br >
     <input type="submit" value="Submit" />
    {/exp:safecracker}

    Additionally, you’ll need the SafeCracker File filetype installed in Addons > Filetypes (comes with EE) and then set the image field of the gallery matrix field as type ‘SafeCracker File’. Phew!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases