Community Documentation

Dynamic Bookmarklets to post content to external site

Last updated February 2, 2009. Created by Mojah on December 15, 2008.
Log in to edit this page.

We used this code to allow site administrators of www.heavenletters.org to select a series of quotations from one site and post it to another site for the creation of a calendar book. The code was placed into a block and the javascript below posted the required cck field data to the external site where the prepopulate module was installed.

<?php
$arg_0
= arg(0);
$arg_1 = arg(1);

  if (
$arg_0 == 'node' && is_numeric($arg_1)) {
   
$node = node_load($arg_1);
    if (
$node->type == 'heavenletter') {
     
$v1 = $node->title;
     
$v2 = $node->field_heavenletter_[0]['value'];
    }
  }

?>

This link will allow you to select text from a page and have that text passed via the url to a cck text field. You will have to change the variables and url to suit your requirements.

<a href="javascript:u=document.location.href;t='<?php print $v1 ?>';p='<?php print $v2 ?>';s=window.getSelection();
void(window.open(%22http://godliners.org/node/add/quotes?edit[field_htitle][0][value]=%22+escape(t)+
'&edit[field_quote][0][value]='+escape(s)+'&edit[field_url][0][value]='+escape(u)+'&edit[field_publishnumber][0][value]='+escape(p),'_blank',
'width=900,height=500,status=yes,resizable=yes,scrollbars=yes')); ">Calendar It!</a>

Page status

No known problems

Log in to edit this page

Site Building Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.