Kentico_RichardS
Hi,
Thank you for your message.
This can indeed be accomplished with a global handler. You can set up the function so that it will be fired upon document update/insert event as per http://devnet.kentico.com/docs/devguide/event_handlers_overview.htm
Then in this you will need to check whether a Tag is assigned to your document (Article_Tags) table. If the Article_Tags is a custom table mapped inside Kentico you can use our API http://devnet.kentico.com/docs/devguide/custom_tables_api_examples_managing_custom_table_data.htm , if its not linked, you can create your own sql query to determin if the record is there. Simple example:
Once you find out that the record is not there you can simply insert it using the API mentioned above.
Let me know if you need anything else.
Kind regards,
Richard Sustek
Hi,
Thank you for your message.
What I want to do, is that when an article is being edited/created, to insert the tag if it doesn't exist yet, and then add the tag id and article id to the Articles_Tags table.
This can indeed be accomplished with a global handler. You can set up the function so that it will be fired upon document update/insert event as per http://devnet.kentico.com/docs/devguide/event_handlers_overview.htm
Then in this you will need to check whether a Tag is assigned to your document (Article_Tags) table. If the Article_Tags is a custom table mapped inside Kentico you can use our API http://devnet.kentico.com/docs/devguide/custom_tables_api_examples_managing_custom_table_data.htm , if its not linked, you can create your own sql query to determin if the record is there. Simple example:
string sql = "SELECT * from Article_Tags something something";
DataSet ds = CMS.SettingsProvider.SqlHelperClass.ExecuteQuery(sql, null, QueryTypeEnum.SQLQuery);
DataRow dr = ds.Tables[0].Rows[0];
string UserName = dr.ItemArray.GetValue(0).ToString();
Once you find out that the record is not there you can simply insert it using the API mentioned above.
Let me know if you need anything else.
Kind regards,
Richard Sustek