Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By gabbardang@gmail.com on
Hi All,
I have been working with drupal, recently i have came up with a requirement.
I have created content types in drupal and i was using drupal forms to store the information. But now i have to do it programitically. Means i need to read the information from a file and create nodes for a already created content type all this through a piece of code without any user interaction on the screen, it can also run as a scheduled backgroud task.
I am not able to find apis for it, can someone help me in pointing to the api or some example code snippet.
Thanks in advance
Kunal
Comments
typing "create node
typing "create node programmatically" into the d.o. search box yields Creating a node programmatically (second link) that has several methods of doing it. I've used the array method successfully, can't speak to the others.
That's the node part anyway. For the rest-- to get the info to populate the node you'll have to read up on parsing files with php (i found this article helpful) then use hook_cron to tie into drupal's cron cycle.
hope that helps....
===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime." -- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz