3

i have a content type and it stores user_email,title,body etc.

Every node has a URL alias.

How can i go through all the node, and extract the email field + the URL of that node.

any clue . thanks

  • you mean you want fetch all email_field and url alias of all nodes? – Yusef Apr 6 '14 at 8:27
  • Do you want get specify content type? – Yusef Apr 6 '14 at 8:28
  • yes , i want to fetch all email_field and url alias of all nodes. – brainHax Apr 6 '14 at 9:17
  • good, do you want get specified content type? – Yusef Apr 6 '14 at 9:19
4

If you want get node of page content type ,you can try another content types

$type = "page"; // machine name for Basic Page
$nodes = node_load_multiple(array(), array('type' => $type)); 
$arr=array();
foreach($nodes as $node){
     arr[$node->nid]['email']= $node->field_email['und'][0]['value'];
     arr[$node->nid]['url_alias']= drupal_get_path_alias('node/'. $node->nid);
    }
  • great. Is there a way that i can put the above code in a file like export.php and run it directly like mywebsite.com/export.php. ? i dont want to ad it in a template file – brainHax Apr 6 '14 at 9:31
  • no,you cant put it in .php file , (of course there is way to do it but not recommended),put it in your custom module – Yusef Apr 6 '14 at 10:47
  • @brainHax you can create a menu link (mywebsite.com/export) from module using hook_menu and output the array in table format ..using theme() function.. Incase if you dont want it in template. – shrish Apr 7 '14 at 3:04
2

You can get url of any particular node using this function

$alias = drupal_get_path_alias('node/102');

Getting email of any node use following statement

$node = node_load(102);
$email = $node->field_email['und'][0]['email']

Make sure I am getting these details of NodeID 102 in above example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.