Saturday, December 5th, 2009 (updated 26 Apr ’15)

Documentation for External Entries v2.6.4

 
  • Version
    2.6.4
  • Type
    Plugins
  • More info
  • Elsewhere
    "EE Forums thread":http://expressionengine.com/forums/viewthread/145112/ "Devot-ee page":http://devot-ee.com/add-ons/plugins/external-entries/ "Programattically/automatically adding weblog entries":http://expressionengine.com/forums/viewthread/145382/
  • Download

Insert

h2(#insert-function). Parameters for exp:external_entries:insert h3. Required parameters h4. debug= The default value for the debug parameter is "yes". This is a safety measure to avoid inadvertently adding data wrongly. When debug is on, the plugin does not do the insert. Instead, the SQL query and any error messages are displayed within a div of class "insert-entries-message". To activate the plugin, set debug to "no", otherwise no insert will be performed. h4. table= The required table parameter tells the plugin into which database table to insert. h3. Optional parameters h4. allow_php= Lets the plugin's values contain PHP. Values are "y" or "n"; default is "n" (for security). Set to "y" for characters such as greater than/less than signs to not be converted to entities. h4. connection= Set to "persistent" if using an external database and EE's database settings are for non-persistent connections. h4. database= The database parameter is required only if inserting into a table on an external database. In this scenario the hostname, password and username parameters are also required. h4. hostname= The hostname parameter is required only if inserting into a table on an external database. In this scenario the database, password and username parameters are also required. h4. parse= The parse parameter is common for all plugins. Setting its value to "inward" allows the plugin to contain another plugin. h4. password= The password parameter is required only if inserting into a table on an external database. In this scenario the hostname, database and username parameters are also required. h4. username= The username parameter is required only if inserting into a table on an external database. In this scenario the hostname, database and password parameters are also required. h2. Variables for exp:external_entries:insert h4. insert:[column_name] The only variables used by the plugin are the names of the columns with values to insert, preceded by "insert:". h2. Examples for exp:external_entries:insert To insert a row into a table on an external database:
{exp:external_entries:insert 
	hostname="www.cia.gov" 
	database="agencies" 
	username="felix_leiter" 
	password="alimentary" 
	table="field_agents" 
	debug="n"
}
{insert:name}James Bond{/insert:name}
{insert:family_motto}The world is not enough.{/insert:family_motto}
{insert:weapon}Beretta 418{/insert:weapon}
{/exp:external_entries:insert}
To insert an entry into an ExpressionEngine channel is a bit more challenging. First, an EE channel entry is contained in two tables: exp_channel_titles and exp_channel_titles. While the entry_id field in exp_channel_titles is auto-increment, it's not in the exp_channel_data table, so we have to create the row in exp_channel_titles, then immediately select the latest row to get that value, in order to pass it to another invocation of the plugin that does the exp_channel_data insert. But due to parsing order, the plugin can't accept a PHP variable as a value (though this might work with a third-party variables addon such as "Stash":http://devot-ee.com/add-ons/stash) so the two inserts can't be in the same template. The solution is to place the second insert in an embedded template to which we pass the entry_id value. Also, a channel entry won't work without at least the following fields being completed in the exp_channel_titles table: site_id, channel_id, author_id, ip_address, title, url_title, status, entry_date, year, month, day, edit_date Note that adding channel entries requires knowing the actual column name of the field being added. All channel fields are in the format "field_id_[xx]", such as field_id_40. The EE2 cpanel displays each field's ID.

Post a comment

Name:

Email:

Location:

URL:

Your comment:

Remember my personal information
Notify me of follow-up comments?

Please enter the word you see in the image below: