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 Umashankar lahre on
hi.....
when we create custom module, in the controller directory of this module
one .php file is their so what kind of data this .php file will return??
namespace Drupal\my_module\Controller;
class MyModuleController{
public function test() {
return array(
'#markup' ==> t('Hello Word'),
);
}
}
here i am returning simply a string but it is not returning ..
Comments
Is this a one-time thing, or
Is this a one-time thing, or something you will be doing regularly?
it is one time thing..
it is one time thing..
For situations like this, I
For situations like this, I usually write a custom Drush script, using the various API functions to create and save the objects necessary. If you are trying to save nodes, google 'create nodes programmatically' and you can find how to create a node through code.
You'll probably want to dump the data from your python script to a file, then read in that file with PHP and create your nodes one by one with your script.
To create a drush script, you'll want to look at hook_drush_command(). To read in a PHP file you can use file_get_contents(), although if that uses too much memory, then you'll want to look at fopen() fread() and fclose().
If you don't want to write code, then you should dump your python script to a .csv file (for example) and look at using the Feeds module to import .csv.
Maybe one of these is helpful
Maybe one of these is helpful:
http://quentinsf.com/writings/drupy/
https://www.drupal.org/project/console
Maybe this helps to you
https://www.drupal.org/node/231117
https://groups.drupal.org/node/44864
Start a new thread for a new
Start a new thread for a new topic. Don't change the entire topic - the original response are now entirely irrelevant.
Can one of the mods please revert this to the original topic.