We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30328
    • 35 Posts
    Hi,

    I’m trying to make it possible for users to MaxiGallery galleries via the front-end. I have new galleries constructed with NewsPublisher, which is fine. However, I would like to make it possible for the user to change the gallery title, description (which are the document title and description), and hopefully the alias from the gallery management page.

    Essentially I would like a form that a user can fill in, that changes the current document title, description, and alias (which I will put on the gallery management page). I’m a bit stuck on how to do this. How can I construct this? Are there any snippets that already give this functionality?

    Tommy T.
      • 30328
      • 35 Posts
      Just in case someone in the future is also wondering about this, I figured it out:

      I used the NewsEditor snippet, and in the template for the form I fix the "editid" to the id of the current page being ("[*id*]"), and initialise the form fields with the title and description of the page, [*pagetitle*] etc... Not too hard!

      Tommy T.
        • 34017
        • 898 Posts
        Tommy,

        Could you explain this in a little more detail or post the markup of the page?

        Thanks,
        Chuck
          Chuck the Trukk
          ProWebscape.com :: Nashville-WebDesign.com
          - - - - - - - -
          What are TV's? Here's some info below.
          http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
          http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
          • 30328
          • 35 Posts
          Hi Chuck,

          Sorry I was very brief in my explanation. The main thing is to have a snippet call to NewsEditor (note that in my case I have made a modified version GalleryNewsEditor, which I will explain below).
          [!GalleryNewsEditor? &folder=`54` &aliastitle=`1` &formtpl=`myGalleryEditTitleTpl`&canpost=`PhotoEditors` &template=`myGalleryTemplate` &clearcache=`1`!]

          This call I put in the manageOuterTpl chunk for MaxiGallery (as well as all the usual placeholders for uploading/sorting photos). The chunk myGalleryEditTitleTpl is:
          <form id="createGalleryForm" method="post" action="[~[*id*]~]">
          <div>
          <input name="NewsEditorForm" type="hidden" value="on" />
          <input name="editid" type="hidden" value="[*id*]" />
          <p>Gallery Title: <input name="pagetitle" type="text" size="40" value="[*pagetitle*]" /></p>
          <p>Gallery Description: <input name="description" type="text" size="40" value="[*description*]" /></p>
          <p class="bottom"><a href="javascript:document.forms['createGalleryForm'].submit()">Save title and description</a></p>
          </div>
          </form>
          

          The important things to note is in the hidden "editid" field the ID is set to that of the current page, and the description and pagetitle are set to those of the current page.

          One small complication (which I didn’t mention in my post at all), is that placing the call in the manageOuterTpl chunk means that is is not processed unless MaxiGallery is "manager" mode. This means that when the form is submitted to the current page "[~[*id*]~]", which will then not be in "manager" mode, the NewsEditor snippet will not run (and not change the title and description of the page). Thus in the chunk for the MaxiGallery galleryOuterTpl I put a "dummy" call to NewsEditor
          [!GalleryNewsEditor? &folder=`54` &aliastitle=`1` &formtpl=`myGalleryEditTitleDummyTpl`&canpost=`PhotoEditors` &template=`myGalleryTemplate` &clearcache=`1`!]

          And have the chunk "myGalleryEditTitleDummyTpl" contain only a single space, and nothing else: this will process the incoming POST variables from the manager page (the new page-title and description). There are probably other ways of achieving this but it works for me.

          Note that my modified news editor snippet has two main modifications:
          1. I remove the test for empty content. You don’t have to do this if you want some content, or you could add as hidden field in the templates with some dummy content as the value.
          2. I use friendly URLs on my site. I change the part in NewsEditor that forwards to the friendly alias to forward to index.php?id=$postid. This avoids some cache problems with newly created/changed aliases. If you don’t use friendly urls, or set a fixed $postid in your calls to NewsEditor you probably don’t need to do this.

          I hope this helps,

          Tommy T.