We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10152
    • 156 Posts
    Hi, sorry for my bad english wink

    I am testing revolution beta 4 to build a site containing up to 10000 user generated documents maybe more.

    On submitting a formulary, the members can create a document that will be filled with $_POST values, like this :
    $title=$_POST['title'];
    $entry=$_POST['entry'];
    $price=$_POST['price'];     // dont forget sanitizing
    
    $doc = $modx->newObject('modDocument');
    $data = array(
    			'pagetitle'   	=> $title,
    			'alias'   	=> insertDate().'-'.makeAlias($title),
    			'template'   	=> 2,
    			'introtext'   	=> substr($entry,0,255),
    			'content'     	=> $entry,
    			'context_key'  	=> 'web'
    		);
    

    Allright this works fine.

    Now in the manager I have created some custom TVs linked to that document (price, ...) and I would like to set the $_POST[’price’] value into the database by adding an entry in the table modx_site_tmplvar_contentvalues.

    I have no idea how to proceed and the doc doesn’t help.
    Does someone know the api/xpdo calls that could do it ?


    Thanks in advance




      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: French at Feb 23, 2010, 12:52 PM

      I am testing revolution beta 4 to build a site containing up to 10000 user generated documents maybe more.
      I hope those are isolated into reasonable quantities in separate contexts. 10,000 Resources in MODx is not going to be efficient.

      Quote from: French at Feb 23, 2010, 12:52 PM

      On submitting a formulary, the members can create a document that will be filled with $_POST values, like this :
      $title=$_POST['title'];
      $entry=$_POST['entry'];
      $price=$_POST['price'];     // dont forget sanitizing
      
      $doc = $modx->newObject('modDocument');
      $data = array(
      			'pagetitle'   	=> $title,
      			'alias'   	=> insertDate().'-'.makeAlias($title),
      			'template'   	=> 2,
      			'introtext'   	=> substr($entry,0,255),
      			'content'     	=> $entry,
      			'context_key'  	=> 'web'
      		);
      

      Allright this works fine.

      Now in the manager I have created some custom TVs linked to that document (price, ...) and I would like to set the $_POST[’price’] value into the database by adding an entry in the table modx_site_tmplvar_contentvalues.

      I have no idea how to proceed and the doc doesn’t help.
      Does someone know the api/xpdo calls that could do it ?
      <?php
      //assuming you have successfully saved the $doc
      $tv = $modx->getObject('modTemplateVar', array('name' => 'price'));
      $tv->setValue($doc->get('id'), $_POST['price']);
      $tv->save();
      ?>

        • 10152
        • 156 Posts
        Thanks a bunch for the code !

        documents are not separated in contexts but I plan to group them in containers by month, each month => a new container will be generated
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: French at Feb 23, 2010, 02:58 PM

          Thanks a bunch for the code !

          documents are not separated in contexts but in containers by month, each month => a new container
          You might consider not caching the Contexts to avoid loading metadata for all 10,000 Resources on every page request. This will increase the load time of any uncached Elements that rely on Context data (the context cache preloads a map of all the pages/URLs as well as source for the plugins that apply to a particular context) because they would have to fetch that data on demand. But if you properly cache all your Resources and the Elements on them, this may perform better than loading such a large context cache file on every request.