We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39706
    • 34 Posts
    Tell me, what am I doing wrong? snippet:
    $gallery = $modx->getService('gallery','Gallery',$modx->getOption('gallery.core_path',null,$modx->getOption('core_path').'components/gallery/').'model/gallery/',$scriptProperties);
          if (!($gallery instanceof Gallery)) return '';
          $modx->lexicon->load('gallery:web');
          $store = $modx->newObject('galItem');
          $store->fromArray(array(
            'id' => NULL,
            'name' => trim($_POST['title']),
            'filename' => intval($_POST['category']).'/',
            'description' => trim($_POST['descr']),
            'mediatype' => 'image',
            'createdon' => strftime('%Y-%m-%d %H:%M:%S'),
            'createdby' => intval($_POST['uid']),
            'active' => '1',
            'watermark_pos' => 'tl'
          ));
          $store->save();
      • 26903
      • 1,336 Posts
      You don't need the 'id=NULL', the id is generated for you, also which album are you putting this in, you may need to specify this also, its more correct to get your album, then do an 'addMany' on it to add the new item.
        Use MODx, or the cat gets it!
        • 39706
        • 34 Posts
        Yes, I saw the binding elements of the categories in the table gallery_album_items. And could you help write this snippet correctly?