OnBeforeBlogAdd
bool handler function( array &arParams );
The event is called in the CBlog::Add before inserting into a blog, and can be used to cancel the inserting or for reconfiguring of certain fields.
Function parameters
Parameter | Description |
---|---|
arParams | Array of fields for blog. |
All parameters of this handler are links to initial variables. That's why, if you modify parameter value inside the handler, it will lead to modified initial variable, received on input of handler function.
Returned value
To cancel the adding process and to terminate execution of the CBlog::Add method, you must create an exception in the handler function by theSee Also
- "OnBlogAdd" event
- CBlog::Add
Example
<? // /bitrix/php_interface/init.php file // register the handler AddEventHandler("blog", "OnBeforeBlogAdd", Array("MyClass", "OnBeforeBlogAddHandler")); class MyClass { // create the event handler "OnBeforeBlogAdd" public static function OnBeforeBlogAddHandler(&$arFields) { if(strlen($arFields["DESCRIPTION"])<=0) { global $APPLICATION; $APPLICATION->throwException("Enter blog description."); return false; } } } ?>
© «Bitrix24», 2001-2024