I have an Articles module (based off http://docs.getfuelcms.com/modules/tutorial#articles_module), and the client wants the option to upload XML files on the server with the article data, and set up a Cron job to add them to the database daily. Any idea how I could connect this to Fuel?
Are you wanting to upload XML files and associate them with each article or just have a place to upload XML files in general without necessarily relating them to an article? Regarding the cron jobs, you may want to try the Cronjobs module: https://github.com/daylightstudio/FUEL-CMS-Cronjobs-Module
Each XML file has the content for one article (title, author, content, etc.). They can easily export their entire newspaper this way, so they want it automated now instead of having someone enter articles manually (but they still want to edit them in Fuel). I was hoping the script could be connected to the module, so I can keep some of the functionality (like image resizing), if that makes sense. I'm just not sure where to start.
All of the articles (XML files) and images will be uploaded to a folder in the root directory called uploads, for example. In each XML file, if there's an image for that article, it has:
<media media-type="image">
<media-reference source="filename.jpg" />
<media-caption><p>Photo caption.</p></media-caption>
</media> So I need to parse the XML data, save it to the articles table, rename and resize the image, and save it to assets/images/articles. Do you think this should be done with an advanced module? I'm not really sure where to start.
I would first focus on the developing the upload, parsing, saving, renaming and resizing logic you mentioned first using a controller that extends the Module controller (perhaps in a "fuel" subfolder fuel/application/controllers/fuel/articles.php). A good example of this to look at is either the fuel/modules/fuel/controllers/pages.php or navigation.php controller. They both have buttons that take you to a separate page to upload a file (pages has an upload method on it).
Then in your modules config file (MY_fuel_modules), for your articles module, you can add the following (just like the pages module does in fuel/modules/fuel/config/fuel_modules.php) to add a button in the list view: ...
'list_actions' => array('articles/upload' => lang('btn_upload')),
'item_actions' => array('save', 'view', 'publish', 'delete', 'duplicate', 'replace', 'create', 'others' => array('articles/upload' => lang('btn_upload'))),
... Lastly, if you don't use the subfolder "fuel" for your controllers, you may need to create a route to map it to fuel/articles: $route[FUEL_ROUTE.'articles'] = 'my_folder/articles';
$route[FUEL_ROUTE.'articles/(.*)'] = 'my_folder/articles/$1';
Comments
https://github.com/daylightstudio/FUEL-CMS-Cronjobs-Module
http://forum.getfuelcms.com/discussion/1863/image-upload-with-custom-saving-data#Item_2
However, in the on_after_post hook, you would add the code for processing the xml file there.
http://docs.getfuelcms.com/general/models#hooks
Let me know if this helps.
<media media-type="image"> <media-reference source="filename.jpg" /> <media-caption><p>Photo caption.</p></media-caption> </media>
So I need to parse the XML data, save it to the articles table, rename and resize the image, and save it to assets/images/articles. Do you think this should be done with an advanced module? I'm not really sure where to start.
Then in your modules config file (MY_fuel_modules), for your articles module, you can add the following (just like the pages module does in fuel/modules/fuel/config/fuel_modules.php) to add a button in the list view:
... 'list_actions' => array('articles/upload' => lang('btn_upload')), 'item_actions' => array('save', 'view', 'publish', 'delete', 'duplicate', 'replace', 'create', 'others' => array('articles/upload' => lang('btn_upload'))), ...
Lastly, if you don't use the subfolder "fuel" for your controllers, you may need to create a route to map it to fuel/articles:
$route[FUEL_ROUTE.'articles'] = 'my_folder/articles'; $route[FUEL_ROUTE.'articles/(.*)'] = 'my_folder/articles/$1';