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

Jaypan’s picture

Is this a one-time thing, or something you will be doing regularly?

Umashankar lahre’s picture

it is one time thing..

Jaypan’s picture

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.

steeph’s picture

Jaypan’s picture

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.