/[drupal]/contributions/modules/prepopulate/USAGE.txt
ViewVC logotype

Diff of /contributions/modules/prepopulate/USAGE.txt

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.3, Mon Jun 23 14:50:42 2008 UTC revision 1.4, Thu Oct 8 02:29:14 2009 UTC
# Line 1  Line 1 
1  $Id: USAGE.txt,v 1.2 2008/03/12 21:17:50 add1sun Exp $  $Id: USAGE.txt,v 1.2.2.1 2009/10/07 23:19:40 brauerranch Exp $
2    
3  See README.txt for a description of this module.  See README.txt for a description of this module.
4  See this documentation online at http://drupal.org/node/228167.  See this documentation online at http://drupal.org/node/228167.
# Line 15  With 'non-clean' urls: Line 15  With 'non-clean' urls:
15    http://www.example.com?q=node/add/content&edit[title]=This is the title    http://www.example.com?q=node/add/content&edit[title]=This is the title
16    
17    
18    POST Requests
19    -------------
20    Since Prepopulate uses the $_REQUEST variable, you have access to prepopulate
21    form values from either GET request in the URL, or the form POST requests. In
22    the below example, we prepopulate a node form's title based on a POST Request:
23    
24    <html><body>
25      <form method="post" action="http://example.com/node/add/story">
26        Title: <input type="text" size="12" maxlength="12" name="edit[title]">
27        <input type="submit">
28      </form>
29    </body></html>
30    
31    
32  How to find what variable to set  How to find what variable to set
33  --------------------------------  --------------------------------
34    
# Line 72  Body fields are different. Though their Line 86  Body fields are different. Though their
86    name="body" rows="20" cols="60"/>    name="body" rows="20" cols="60"/>
87    
88  You can't just take the name "body," throw it into a edit[body] and  You can't just take the name "body," throw it into a edit[body] and
89  expect it to work. Drupal wraps the body field into a "body_filter"  expect it to work. Drupal wraps the body field into a "body_field"
90  array when it gets processed. So, for body fields, a URL like:  array when it gets processed. So, for body fields, a URL like:
91    
92    http://www.example.com/node/add/content?edit[body_filter][body]=This is the body    http://www.example.com/node/add/content?edit[body_field][body]=This is the body
93    
94  ought to do the trick.  ought to do the trick.
95    
 Contact forms  
 -------------  
 You can use prepopulate to fill in forms created by the core Contact module as well. Something like:  
   
 http://d6/contact?edit[cid]=2  
96    
97  Multiple fields  Multiple fields
98  ---------------  ---------------
# Line 91  Multiple fields Line 100  Multiple fields
100  Prepopulate can handle pre-filling multiple fields from one URL. Just  Prepopulate can handle pre-filling multiple fields from one URL. Just
101  separate the edit variables with an ampersand:  separate the edit variables with an ampersand:
102    
103    http://www.example.com/node/add/content?edit[title]=The title&edit[body_filter][body]=The body    http://www.example.com/node/add/content?edit[title]=The title&edit[body_field][body]=The body
104    
105  You're already using the ampersand with non-clean URLs:  You're already using the ampersand with non-clean URLs:
106    
107    http://www.example.com?q=node/add/content&edit[title]=The title&edit[body_filter][body]=The body    http://www.example.com?q=node/add/content&edit[title]=The title&edit[body_field][body]=The body
108    
109    
110  Escaping special characters  Escaping special characters
# Line 115  that illegal characters are properly enc Line 124  that illegal characters are properly enc
124  Bookmarklets  Bookmarklets
125  ------------  ------------
126    
127  Prepopulate.module was created for bookmarklets. Here is the actual  Prepopulate.module was created for bookmarklets. Here is a bookmarklet for
128  bookmarklet I use to post web links to my site:  posting web links to a site:
129    
130  javascript:u=document.location.href;t=document.title;s=window.getSelection();void(window.open(%22http://oif.eafarris.com/node/add/content-web-link?edit[title]=%22+escape(t)+'&edit[body_filter][body]='+escape(s)+'&edit[field_url][0][value]='+escape(u),'_blank','width=1024,height=500,status=yes,resizable=yes,scrollbars=yes'));  javascript:u=document.location.href;t=document.title;s=window.getSelection();void(window.open(%22http://example.com/node/add/content-web-link?edit[title]=%22+escape(t)+'&edit[body_field][body]='+escape(s)+'&edit[field_url][0][value]='+escape(u),'_blank','width=1024,height=500,status=yes,resizable=yes,scrollbars=yes'));
131    
132  This turns into a URL like this:  This turns into a URL like this:
133    
134  http://oif.eafarris.com/node/add/content-web-link?edit[title]=drupal.org%20%7C%20Community%20plumbing&edit[body_filter][body]=&edit[field_url][0][value]=http%3A//drupal.org/  http://example.com/node/add/content-web-link?edit[title]=drupal.org%20%7C%20Community%20plumbing&edit[body_field][body]=&edit[field_url][0][value]=http%3A//drupal.org/
135    
136  If I had first selected some text on the page, it would be put into the  Selecting some text on the page first would put that text into the
137  body of the node.  body of the node.
138    
139  Happy prepopulating!  Happy prepopulating!

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.2