What I should do, when a new news page is added, should trigger an event that will send an API request with news page name and news page content. I should receive that content from EE and put that data in my HTML string and after that send it. The same for the news page updated. I found that article in the documentation but I never worked with PHP and EE before and not sure where to paste it. Please help ASAP! Thank You!
https://docs.expressionengine.com/latest/development/extension-hooks/cp/publish.html#entry_save_and_close_redirectentry
You want to post some news in EE that then executes an API posting it to SalesForce? Or the other way around? From SalesForces to EE?
Yes, the first one. I should set up news automation for SF Marketing Cloud. Whenever a company creates new news on the EE, I should send this data to the SFMC, but before put that content in my HTML CSS container. LIke: ‘<style> div {color: red;}</style><div>NEWS CONTENT WILL BE THERE</div>’, it will be a simple string;
It sounds like what you want is actually the after_channel_entry_save
hook https://docs.expressionengine.com/latest/development/extension-hooks/model/channel-entry.html#after_channel_entry_saveentry-values.
If you’re unfamiliar with creating an extension. Here is a starter one for you that I generated from https://ee-addon-generator.triplenerdscore.xyz/ : https://drive.google.com/file/d/1tzhleikgP2XY9-QK2OzGyMpemZniC8ZS/view?usp=sharing
You’ll want to capture the entry data after it’s saved, do whatever you want to it in your PHP (ie. putting it into an HTML formatted string), and push that to your SalesForce API endpoint.
so your add-ons go into /system/user/addons
assuming no one has changed the name of your system folder.
https://docs.expressionengine.com/latest/add-ons/overview.html#installing-add-ons
Next, definitely read through the developing extensions guide here: https://docs.expressionengine.com/latest/development/extensions.html
Regarding debugging, it’s like any other PHP app. You can use tools like Xdebug if that’s what you like. Especially for extensions I like to just write values to files or die and echo out the values so I can see what data is available. I’m not the best extension developer, but if you have zero time, that might be the best way to start. Dump the $values in the extension, then go into EE and save an entry. You’ll see what’s then available.
Here was a conference talk on using Xdebug with EE.. https://www.youtube.com/watch?v=nxr2XjFfpgs&list=PL5elGX70z1bhTWETdrvbLA5pOPIDEe9c7&index=12
You can also look for free EE add-ons out there and browse them to see how they are using extensions.|
Hi there! I did it, wrote an extension which on update or creates new entry will send data to the SFMC. Now I get stuck on identifying a new entry type, I should do it only on the news. Maybe I can query it by Entry name and identity that is news? Please help me with it. Values coming from hook don’t show me that.
@Andrii, are you trying to get the channel name? Or do you have a field on your entry called type
?
@Andrii
So, if you are using the after_channel_entry_save
hook, you should be able to get the Channel off of the entry.
The hook comes in like this:
after_channel_entry_save($entry, $values)
So you should be able to do this.
$channel = $entry->Channel;
$channelName = $channel->channel_name;
You can get the channel ID off of the values and query the model yourself.
$channelId = $values['channel_id'];
$channel = ee('Model')->get('Channel')->filter('channel_id', $channelId)->first();
$channelName = $channel->channel_name;
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.