You’ve got it. Post an example from your state/county file and I’ll get you started on the snippet.
Wow Bob,
That sounds great. I wish I had thought of that. So we’re parsing that CSV file or what-have-you, and the snippet issues a command to create a doc from each data item when it runs? Or have I lost it, and just need feeding?
I’m peering quizically at the API, and can’t quite find something for creating a doc programatically. Any places you can point me to a clue for that?
Thanks! Dave
btw, when you’re taking a quiz, you could be said to be quizzical. When you’re taking a test, you could be said to be....?????

Thanks Bob...
If I understand correct, the snippet will generate the documents based on the csv file. So there will be 50 .csv files in the same folder each named for a state. I have attached an example of a state csv file set up the way I think you are suggesting but I’m not sure how to set up the snippets/chunks to parse the data.
Thanks for the help!
[[!MakeStates? &stateList=`Alabama,Arkansas,Arizona`]]
<?php
/* Make States Snippet */
$delimiter = "\n\r"; // (could be a comma instead)
/* get list of state files from parameter */
$states = explode(',',$stateList);
$path = "path/to/files/";
/* This will hold the menu for all states */
$stateLinks = '<ul>';
foreach($states as $state) {
$content = '<ul>'; // beginning of county menu
$filepath = $path . $state;
$text = file_get_contents($filename);
if ($text === false) {
return "failed to get file contents";
}
/* create state resource */
$fields = array(
'pagetitle'=>$state,
'longtitle'=>$state,
'alias'=>$state,
'published'=>'1',
);
$stateObj = $modx->newObject('modResource',$fields);
$stateObj->save();
$stateId = $stateObj->get('id'); // get state id to be county page parent
$stateLinks .= "\n" . '<li><a href = "[[~' . $stateId . '"</a>' . $state . '</a></li>';
/* create county pages */
$counties = explode($delimiter,$text);
if (count($counties) < 5) {
return 'Something is wrong -- too few counties';
}
foreach($counties as $county) {
$county = trim($county); // trim extraneous characters from county name
$pagetitle = $county;
$longtitle = $pagetitle;
$alias = tolower($county);
$alias = str_replace(' ','-',$alias);
$parent = $stateId;
$fields = array(
'pagetitle'=>$pagetitle,
'longtitle'=>$longtitle,
'alias'=>$alias,
'parent'=>$parent,
'published'=>$parent;
);
//create county resource
$countyObj = $modx->newObject('modResource',$fields);
$countyObj->save();
$countyId = $countyObj->get('id');
// add link for county to state page menu
$content .= "\n" . '<li><a href="[[~' . $countyId . ']]>' . $county . '</a></li>';
} /* end foreach county */
// end county menu
$content .= '</ul>';
/* might have to re-get the state object with $modx->getObject here */
/* add county menu to state page */
/* might have to re-get the state object with $modx->getObject here */
$stateObject->setContent($content);
$stateObject->save();
} /* end foreach state */
/* Make all state page */
$stateLinks = '</ul>';
$fields = array(
'pagetitle'=>'All States',
'longtitle'=>'All States',
'alias'=>'all-states';
'published'=>'1',
);
$allStateObj = $modx->newObject('modResource',$fields);
$allStateObj->setContent($stateLinks);
$allStateObj->save();
return "Pages Created";
<?php
/* Make States Snippet */
$delimiter = "\n\r"; // (could be a comma instead)
/* get list of state files from parameter */
$states = explode(',',$stateList);
$path = "assets/states/";
/* This will hold the menu for all states */
$stateLinks = '<ul>';
foreach($states as $state) {
$content = '<ul>'; // beginning of county menu
$filepath = $path . $state;
$text = file_get_contents($filename);
if ($text == false) {
return "failed to get file contents";
}
/* create state resource */
$fields = array(
'pagetitle'=>$state,
'longtitle'=>$state,
'alias'=>$state,
'published'=>'1',
);
$stateObj = $modx->newObject('modResource',$fields);
$stateObj->save();
$stateId = $stateObj->get('id'); // get state id to be county page parent
$stateLinks .= "\n" . '<li><a href="[[~' . $stateId . ']]">' . $state . '</a></li>';
/* create county pages */
$counties = explode($delimiter,$text);
if (count($counties) < 5) {
return 'Something is wrong -- too few counties';
}
foreach($counties as $county) {
$county = trim($county); // trim extraneous characters from county name
$pagetitle = $county;
$longtitle = $pagetitle;
$alias = tolower($county);
$alias = str_replace(' ','-',$alias);
$parent = $stateId;
$fields = array(
'pagetitle'=>$pagetitle,
'longtitle'=>$longtitle,
'alias'=>$alias,
'parent'=>$parent,
'published'=>$parent;
);
//create county resource
$countyObj = $modx->newObject('modResource',$fields);
$countyObj->save();
$countyId = $countyObj->get('id');
// add link for county to state page menu
$content .= "\n" . '<li><a href="[[~' . $countyId . ']]">' . $county . '</a></li>';
} /* end foreach county */
// end county menu
$content .= '</ul>';
/* might have to re-get the state object with $modx->getObject here */
/* add county menu to state page */
/* might have to re-get the state object with $modx->getObject here */
$stateObject->setContent($content);
$stateObject->save();
} /* end foreach state */
/* Make all state page */
$stateLinks = '</ul>';
$fields = array(
'pagetitle'=>'All States',
'longtitle'=>'All States',
'alias'=>'all-states';
'published'=>'1',
);
$allStateObj = $modx->newObject('modResource',$fields);
$allStateObj->setContent($stateLinks);
$allStateObj->save();
return "Pages Created";
):$text = file_get_contents($filename);
$text = file_get_contents($filepath);
if (! file_exists($filepath)) {
return 'No file at: ' . $filepath;
}<p>Creating States and Counties . . . </p> [[!MakeStates? &stateList=`Alabama,Arkansas,Arizona`]]