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

    I’ve found a nice thread here about how to create a multiuser gallery with MaxiGallery. Now I know I have to create a new document for every user’s gallery but I do not know how to do this rolleyes. It should work on some way with the doc manager but can anybody explain me how?! I didn’t found something about that or it is simply too late today :’(.

    regards,
    Max
      I love MODx
      • 31133
      • 22 Posts
      I think it could be interesting for you to check: docApi.

      It’s a snippet and it seems very easy to use.

      Good luck,
      Uri
        • 24806
        • 43 Posts
        Okay, thanks.
        But there’s another problem:
        I tried to create a new document with the docAPI but it returns a SQL error:

        Column ’alias’ specified twice

        SQL: INSERT INTO `personalizer`.data_site_content SET id = ’’,parent = ’’,pagetitle = ’’,longtitle = ’’,alias = ’’,menutitle = ’’,menuindex = ’’,description = ’’,introtext = ’’,published = ’’,pub_date = ’’,unpub_date = ’’,hidemenu = ’’,searchable = ’’,cacheable = ’’,richtext = ’’,template = ’’,type = ’’,contentType = ’’,isfolder = ’’,privateweb = ’’,privatemgr = ’’,hasmetatags = ’’,haskeywords = ’’,createdby = ’’,publishedby = ’’,donthit = ’’,content_dispo = ’’,content = ’’,published = ’0’,pub_date = ’’,unpub_date = ’’,alias = ’Array’;

        Here’s my abstracted snippet call:
        		$objDocAPI = new docAPI();
        		$objDocAPI->resetObject();
        		$objDocAPI->setObject(0,'*');
        		$objDocAPI->save();
        


        I tried a few different strings for the setObject’s second parameter function (’alias,content’,’alias’,’content’) but I get the same error every time!
        Did I put it the wrong way or is there an error in the docAPI code?

        regards from Berlin, the city of "Carneval of the Cultures" grin,
        Max
          I love MODx
          • 31133
          • 22 Posts
          I think you ve got the field alias twice in your SQL sentece.
            • 24806
            • 43 Posts
            Really?! grin grin grin
            Yeah, I think that is my problem. I am only asking myself if I have to change the code of the docAPI or if there is a way to give it other params for not having this error. I’ll have a look in the code.

            regards,
            Max
              I love MODx
              • 24806
              • 43 Posts
              I know it is a long time ago but I’d like to post my simple solution here to close this topic. The docAPI didn’t work, so that I had to write it myself and it is much easier as I thought grin.
              $sql = "INSERT INTO ".$modx->getFullTableName("site_content")."
                 (type, contentType, pagetitle, longtitle, description, published, parent, content, richtext, template, cacheable)
                 VALUES('document','text/html','Gallery','".$userid."','Gallery','1','6','[[setProfileContent? &display=`[!displayGallery!]`]]','0','0','0');";
              
              if(!$rs = $modx->db->query($sql))
                 die('buuuuuhuuuhuuuuuuu, you don't have a gallery!');
              

              In this case I create a new document for a web user to manage his MaxiGallery gallery which is ajax-driven. The snippet call is generated by another snippet.
              If the page is ready I’ll post the link somewhere here cool.

              regards,
              Max
                I love MODx