
$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'
);
I hope those are isolated into reasonable quantities in separate contexts. 10,000 Resources in MODx is not going to be efficient.
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 ?
<?php
//assuming you have successfully saved the $doc
$tv = $modx->getObject('modTemplateVar', array('name' => 'price'));
$tv->setValue($doc->get('id'), $_POST['price']);
$tv->save();
?>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.
Thanks a bunch for the code !
documents are not separated in contexts but in containers by month, each month => a new container