Answers.Body: <p>You could use the <a href="http://buildwithcraft.com/docs/plugins/events-reference#entries-onSaveEntry" rel="nofollow">entries.onSaveEntry</a> event to get entries as they're saved, check the publish date, then loop through its properties, and check the paths on any assets.</p>
  
  <p>You'd probably also want to hook into <a href="http://buildwithcraft.com/docs/plugins/events-reference#entries-onDeleteEntry" rel="nofollow">entries.onDeleteEntry</a> to de-index any assets from entries that get deleted.</p>
  
  <p><strong><em>Please note:</strong> this won't auto-index entries that were scheduled to publish at a later date.</em></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-19T05:15:22.230Z
Answers.Text: There are also events for assets: [Asset API Events](http://buildwithcraft.com/docs/plugins/events-reference#asset-api-events).
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-19T21:01:20.043Z
Answers.LastActivityDate: 2015-07-19T21:01:20.043Z
Answers.UserDisplayName: Rick
Answers.Body: <p>The <a href="https://github.com/iainurquhart/craft_introvert" rel="nofollow noreferrer">Craft Introvert</a> might be what you're looking for...</p>
  
  <p><img src="https://i.sstatic.net/4FkwX.png" alt="enter image description here"></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-19T20:54:43.857Z
Answers.Text: Actually, disregard that. A post-caffeine re-read says I misread your question, sorry.
Answers.UserDisplayName: Rick
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-19T20:48:49.980Z
Answers.LastActivityDate: 2015-07-19T20:48:49.980Z
Answers.UserDisplayName: Rick
Body: <p>So, i must write this Craft plugin to index documents as soon as they are published, though a special publication field used amongst different pages templates (including a matrix field !).</p>
  
  <p>How can i use the publish event to detect that this special kind of assets (assets belonging to a special directory) have been used ?</p>
  
Tags: <plugin-development><events>
Title: How can i detect that an asset has been published from a plugin?
ThreadText: # How can i detect that an asset has been published from a plugin?
  
  (Asked by: username_0 on 2015-07-18)
  
  So, i must write this Craft plugin to index documents as soon as they are published, though a special publication field used amongst different pages templates (including a matrix field !).
  
  How can i use the publish event to detect that this special kind of assets (assets belonging to a special directory) have been used ?
  
  **Tags:** plugin-development, events
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-07-19. Score: 2 | Accepted answer
  
  You could use the [entries.onSaveEntry](http://buildwithcraft.com/docs/plugins/events-reference#entries-onSaveEntry) event to get entries as they're saved, check the publish date, then loop through its properties, and check the paths on any assets.
  
  You'd probably also want to hook into [entries.onDeleteEntry](http://buildwithcraft.com/docs/plugins/events-reference#entries-onDeleteEntry) to de-index any assets from entries that get deleted.
  
  ***Please note:*** this won't auto-index entries that were scheduled to publish at a later date.
  
  > **Comments:**
  > **username_2**: There are also events for assets: [Asset API Events](http://buildwithcraft.com/docs/plugins/events-reference#asset-api-events).  
  
  ---
  
  ### Answer by username_1 on 2015-07-19. Score: 0
  
  The [Craft Introvert](https://github.com/iainurquhart/craft_introvert) might be what you're looking for...
  
  ![enter image description here](https://i.sstatic.net/4FkwX.png)
  
  > **Comments:**
  > **username_1**: Actually, disregard that. A post-caffeine re-read says I misread your question, sorry.  
  
  ---
  
  