2

I'm using entity reference prepopulate and views. On the start of my node add form I'm using views to display some products and I have created a PHP button to pass the nid of those products to the URL. Here is the code:

<?php 
$url = token_replace('[current-page:url]'); 
$l = l( t('SELECT THIS VENUE'), $url,  array('query' => array('field_product_venue' =>$row->nid )  ));
echo $l; 
?>

And on the last part of my node add form the user can see the summary of all the products he or she has chosen but he or she must also have the ability to remove those items, since the form gets its selected products from the url I want to create a button that deletes that specific product (nid) from the URL.

Any help would be greatly appreciated.

1 Answer 1

0

You need to get the value of the parameter, then check if the parameter contains the nid, then replace/remove the nid on your parameter from your url.

Use this code on your Views: PHP

<?php 
$url = token_replace('[current-page:url]');
$venue =$_GET['field_product_venue'];
if (strpos($venue, $row->nid) !== false) {
$change= str_replace($row->nid .',', '', $venue);
$l = l( t('DELETE'), $url,  array('query' => array('field_product_venue'=>$change)  ));
echo $l;    
}
?>
1
  • Looks promising will try later. :D Commented Apr 21, 2015 at 1:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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