Automatically Create New Pages With Content From Database
PermalinkWe have a preexisting database of products. I would like to write a php script that will generate a new set of Concrete5 pages for a product using content from the database so that we only have to enter the data once. Then once the Concrete5 pages are setup we have a nice CMS to easily edit those pages in the future if need be. We do not have to have the pages sync with the database or anything fancy like that, just the initial setup is all we're after right now.
Now, I am an all out beginner with C5. What I have struggled with so far is that I cannot actually find a fully working example of how to use the C5 API. There are plenty of code snippets yes, but I do much better when I can work backwards from something that already works. If anyone can provide me with an example like that and some guidance towards what API commands I need to generate new pages that would be incredibly helpful.
Best of all if I could get a fully working script that generates a new page with the page title as a PHP variable I am sure I could figure out the rest from there.
Thank you all very much!
https://github.com/jordanlev/c5_package_installer_utils...
I put this script (i.e. import.php) in my top level tools folder and ran it via:
http://mysite.com/index.php/tools/import...
In this script the context is importing builder profiles into a business directory.
<?php $file1 = "/home/mywebsite/public_html/tools/import.txt"; $lines = file($file1); $businesses = array(); // loop through csv and collect/filter data foreach($lines as $line) { $result = explode("\t", $line); array_shift($result); $name = trim($result[0], '"'); $name = ucwords(strtolower($name)); $website = $result[10]; $email = $result[9]; $businesses[] = array( 'name'=>$name,
It's quick and dirty, but it got the job done for an initial import. Be careful with the number of records you import at a time, as I found that it was quite slow (probably because there is a nicer way of doing it!).
How about just a complete example of a working API call in PHP?