I'm not sure there are any resources specific to this use case, but I've built quite a few add-ons which import channel entries.
It's fairly straightforward with just a couple caveats:
Inserting data for more advanced fieldtypes can be a bit tricky. Your best bet is to look at what fields are actually being submitted via the publish form in the control ...
This is a pretty late answer, and you likely already figured it out, but the $data array should use the database 'field_id_#' as the array key. So if the field id of your custom field 'foo' is 5, for example, then your data array would be:
$data = array (
'title' => 'bar',
'url_title' => 'bar',
'field_id_5' => 'bar',
Within the channel entry API, you can pass the data array containing the array of category ids like:
$data = array(
'title' => 'ENTRY TITLE',
'entry_date' => time(),
'channel_id' => x,
You might try creating an RSS feed on the news site. It's fairly easy to setup an XML template and build it out using the standard RSS format, which you can find easily with a Google search.
After you have an RSS template established, you can use the Feed Parser add-on on the other site to read and display the RSS feed contents.
As per your comments, you've already figured out the rather large annoyance of needing to pass all pre-existing fields with the save_entry function or else having them wiped out. I wanted to post an answer here though because there are a couple considerations I've come across when doing entry updates with my add-ons:
1) If you do not need the update to ...
I've managed to tackle this issue myself using the following. The key data structure is immediately below with a full example beneath that. This will handle all the relationship stuff automatically.
Data array structure for relationships
$data = array(
'title' => $title,
'entry_date' => $date,
'edit_date' => $date,
Well, logically the last submitted insert query from the API is in the channel_data table. This tables Primary Key is entry_id, so you could try this CI command after you run the save_entry method:
$new_entry_id = ee()->db->insert_id();
Check to make sure it's returning the correct entry_id. I'm assuming this works within an execution cycle and uses ...
There is no API for adding anything other than fieldtypes or tabs to the entry screen. I'd suggest one of two options:
Yeah, you can save relationship data using below Model query. In below code $entry->field_id_2 indicates the relationship data.
$entry = ee('Model')->make('ChannelEntry');
$entry->channel_id = 'your_channel_id';
$entry->site_id = ee()->config->item('site_id');
$entry->author_id = ee()->session->userdata('member_id');
I too had the same issue, the EE documentation to put it nicely is rather incomplete on this topic. Looking though the source I saw an example in ft.relationships.php:
->fields('Channel.channel_title', 'Children.entry_id', 'Children....
It certainly is!
Here's what you need to do (From the manual) based on your example :
//get the row to edit
$query = ee()->db->select('title, url_title')
So there is no way to do this with the EE API. You need to use the Database class and use the insert function like so.
'site_id' => 1,
'group_name' => 'Group Name'
$group_id = ee()->db->insert_id();
Lots of option here:
Use a 3 level category structure:
Select categories as required for each entry. You can then call all entries in each category, with each deeper level of category refining the results.
Use 3 channels with relationships
Regions channel (no relationships)
Cities channel (relate city to Region entry)
You ideally should figure out a solution to the channel form error you are receiving, but as a possible workaround you will need to create your own add-on to do this.
This is usually best achieved with a module that makes use of ACTions to post your form submission, but as there might be issues with this given the fact that channel forms aren't working ...
I know it seems redundant, but in the Channel Entries API you need to pass the entry_id in the data array. EE looks to that array to determine if the entry is being edit correctly (as far as the hooks go). I have tested this and confirmed it a while back, so I assume it's still true. Without the entry_id in the data array, the entry should get updated but in ...
Check out Rob Sanchez' EE Bootstrap: https://github.com/rsanchez/ExpressionEngine-Bootstrap
It does just what you're looking for. I've used it myself for some projects where I didn't want to put code inside an EE add-on.
Turnes out the $_POST data for my field has everything I needed, and I used it like this:
'field_id_32' => $channel_form_obj->entry('job_photos')
'field_id_32' => $_POST['job_photos']
Makes me wonder why the channel form object did not have that in the first place?
Short answer: there is no API for this.
Longer answer: there is no API, but... You could either check out ObjectiveHTML's Channel Data library. You could also try and utilize the Channel module. However, that path is completely undocumented, so if you decide to go that route, tread lightly.
This StackOverflow answer shows how to extract a variable from a JSON string:
Then echo that variable inside the exp:channel:form tag into a hidden field:
<input type="hidden" name="product_id" value="<?php echo $ID ?>">
I was originally going to post this as a comment, but it's too long, so have opted for an 'answer'.
You should be aware of the security implications of doing this as advised above.
I've just created an add-on to do just this which will be executed via CRON - however, it needs to be pointed out that running: