Publisher does not support the Fluid field type. Please do not contact asking when support will be available.
If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.
Ticket: how to tell the entry is published for the first time
Status | Resolved |
Add-on / Version | Publisher |
Severity | Trivial |
EE Version |
Yuri Salimovskiy
Feb 01, 2013Hi Brian,
I’m creating custom notification add-on for a site that’s running Publisher.
I need to send notification when entry is first published. Checking whether entry_id is set (as with regular workflow) will probably not work, as the entry might already be saved as draft, so entry_id exists. Can you recommend any approach?
Thanks,
Yuri
BoldMinded (Brian)
I’m using the entry_submission_ready hook which looks like this:
So you might be able to use entry_submission_start/end and reference that property to tell if its a brand new entry.
Yuri Salimovskiy
What about this scenario: 1. the entry is created and saved as draft -> notification is not sent 2. entry is published -> notification is sent 3. entry is edited -> notification not sent
I guess that on step 2 $this->EE->publisher_lib->is_new_entry will be FALSE? Because the draft already exists. Or am I wrong here?
BoldMinded (Brian)
Correct, it’ll be false. You can use $this->EE->input->post(‘save_status’) and entry_id, and query the publisher_titles table or you can try to use these methods, both accessible from $this->EE->publisher_entry-> http://pastie.org/6012398
This sounds like a good candiate for a hook in Publisher.
Yuri Salimovskiy
Can you tell me more about “query the publisher_titles”? What specifically should I look for?
BoldMinded (Brian)
Well, if you’ve created a draft and it hasn’t been saved as open/published yet, then there won’t be a record in the publisher_titles table for the entry_id and status of ‘open’, so:
select from publisher_titles where entry_id = ‘123’ and status = ‘open’ - send notification if a row comes back, if no row comes back then its been saved as draft only.
Yuri Salimovskiy
What about if entry was published before, and edited (re-published) afterwards? Can I run some query on publisher_titles (or another table) and NOT send notification in that case?
BoldMinded (Brian)
You’d have to compare the dates, create your own table, or add a column to the publisher_titles table to store which entries have had notifications already sent for.
Yuri Salimovskiy
Thanks. I think I’ll create my own db table then.