Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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

share|improve this question
    
you mean you want fetch all email_field and url alias of all nodes? –  zhilevan Apr 6 at 8:27
    
Do you want get specify content type? –  zhilevan Apr 6 at 8:28
    
yes , i want to fetch all email_field and url alias of all nodes. –  brainHax Apr 6 at 9:17
    
good, do you want get specified content type? –  zhilevan Apr 6 at 9:19

2 Answers 2

up vote 4 down vote accepted

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);
    }
share|improve this answer
    
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 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 –  zhilevan Apr 6 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 at 3:04

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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