User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:devel:add_special_block [2019/03/14 00:12]
joebordes [Create a Business Action]
en:devel:add_special_block [2019/11/10 17:20] (current)
joebordes [Show IFRAME]
Line 3: Line 3:
 The goal of this tutorial is to show how we could add a new block in the detail view of a module where we could add some special functionality that we may need. The goal of this tutorial is to show how we could add a new block in the detail view of a module where we could add some special functionality that we may need.
  
-This is basically a two step process; first we have to add the information into the database so the application knows that it has to load a new block and what code it has to launch to fill it in, then we have to implement that class to generate the output.+This is basically a two-step process; firstwe have to add the information into the database so the application knows that it has to load a new block and what code it has to launch to fill it in, then we have to implement that class to generate the output.
  
-For this tutorial I am simply going to sum the number of Purchase Orders related to a contact and show that in a block on the contacts detail view.+For this tutorialI am simply going to sum the number of Purchase Orders related to a contact and show that in a block on the contacts detail view.
  
 To change the database we use vtlib and add a DetailViewWidget Link using vtlib: To change the database we use vtlib and add a DetailViewWidget Link using vtlib:
Line 48: Line 48:
 The initial idea is the same as above, you need a class that you reference in the DETAILVIEWWIDGET,​ this class returns another class that must implement a //​process()//​ method. What we do is that this second class extends the [[https://​github.com/​tsolucio/​corebos/​blob/​master/​modules/​Vtiger/​DeveloperWidget.php#​L17|class DeveloperBlock]] which gives you a set of predefined functions to help you concentrate only on the actual logic of your requirement. The initial idea is the same as above, you need a class that you reference in the DETAILVIEWWIDGET,​ this class returns another class that must implement a //​process()//​ method. What we do is that this second class extends the [[https://​github.com/​tsolucio/​corebos/​blob/​master/​modules/​Vtiger/​DeveloperWidget.php#​L17|class DeveloperBlock]] which gives you a set of predefined functions to help you concentrate only on the actual logic of your requirement.
  
-Additionally,​ we have modified the DEAILVIEWWIDGET code to permit you to send more parameters into your class.+Additionally,​ we have modified the DEAILVIEWWIDGET code to permit you to send more parameters into your class which is done using the URL parameter syntax. 
 + 
 +<WRAP center round info 60%> 
 +[[http://​blog.corebos.org/​blog/​developerblock|You can find a blog post]] with a step by step example and {{ :​en:​devel:​asktoproceeddevblock.zip |download the related code clicking here.}} 
 +</​WRAP>​ 
  
 The coreBOS Question analytical module has [[https://​github.com/​tsolucio/​corebos/​blob/​master/​modules/​cbQuestion/​cbQuestionWidget.php|an example of the usage of the Developer Block]] which makes it easy to get the execution of the question into a block. Try these steps to see the result: The coreBOS Question analytical module has [[https://​github.com/​tsolucio/​corebos/​blob/​master/​modules/​cbQuestion/​cbQuestionWidget.php|an example of the usage of the Developer Block]] which makes it easy to get the execution of the question into a block. Try these steps to see the result:
Line 58: Line 63:
 {{ :​en:​adminmanual:​bquestion01.png |Business Question}} {{ :​en:​adminmanual:​bquestion01.png |Business Question}}
  
-|Columns:​|[{"​fieldname":"​countres","​operation":"​is","​value":"​count(ticket_title)","​valuetype":"​expression","​joincondition":"​and","​groupid":"​0"​},​{"​fieldname":"​ticketstatus","​operation":"​is","​value":"​ticketstatus","​valuetype":"​fieldname","​joincondition":"​and","​groupid":"​0"​}]| +|Columns:|<​code>​[{"​fieldname":"​countres","​operation":"​is","​value":"​count(ticket_title)","​valuetype":"​expression","​joincondition":"​and","​groupid":"​0"​},​{"​fieldname":"​ticketstatus","​operation":"​is","​value":"​ticketstatus","​valuetype":"​fieldname","​joincondition":"​and","​groupid":"​0"​}]</​code>​
-|Condition:​|[{"​fieldname":"​$(parent_id : (Accounts) account_no) ","​operation":"​is","​value":"​$account_no$","​valuetype":"​raw","​joincondition":"​and","​groupid":"​0"​}]| +|Condition:​|<​code>​[{"​fieldname":"​$(parent_id : (Accounts) account_no) ","​operation":"​is","​value":"​$account_no$","​valuetype":"​raw","​joincondition":"​and","​groupid":"​0"​}]</​code>​
-|Type properties:​|{"​key_label":"​ticketstatus","​key_value":"​countres"​}|+|Type properties:​|<​code>​{"​key_label":"​ticketstatus","​key_value":"​countres"​}</​code>​|
  
 ==== Create a Business Action ==== ==== Create a Business Action ====
Line 77: Line 82:
 |Action:​|module=cbQuestion&​action=cbQuestionAjax&​file=cbQuestionWidget&​QID=43177&​RECORDID=$RECORD$| |Action:​|module=cbQuestion&​action=cbQuestionAjax&​file=cbQuestionWidget&​QID=43177&​RECORDID=$RECORD$|
 |Module:​|Accounts| |Module:​|Accounts|
 +
 +<WRAP center round important 60%>
 +NOTE that the QID value is actually the CRMID of the Business Question you created in the first step, so you MUST change the **43177** above to the one assigned to your record
 +</​WRAP>​
  
 ==== Appearence ==== ==== Appearence ====
Line 83: Line 92:
  
 {{ :​en:​adminmanual:​bquestion02.png |}} {{ :​en:​adminmanual:​bquestion02.png |}}
 +
 +==== Another example: Show Message ====
 +
 +The application has another native developer block that permits you to show a message. Watch the next video to see how that works and learn a little more about how this development resource works.
 +
 +{{youtube>​aAs2FVJ0veE}}
 +
 +==== Another example: Mass Upload Documents ====
 +
 +The application has another native developer block that permits you to mass upload documents. Watch the next video to see how that works and [[https://​github.com/​tsolucio/​corebos/​commit/​889884362b82ff24a8c1b5499f22e7705e55d519|look at the commit to see the code]].
 +
 +{{youtube>​lW3RrQQQb-4}}
 +
 +==== Show IFRAME ====
 +
 +You can show an IFRAME in a block with the **showHTMLBlock**,​ something like this:
 +
 +<​code>​
 +block://​showHTMLBlock:​modules/​Utilities/​showHTMLBlock.php:​op=iframe&​height=400px&​ex=http%3A%2F%2Fcorebos.org%3Fifcrmid%3D%24RECORD%24%26ifmodule%3D%24MODULE%24
 +</​code>​
 +
 +where you are passing to the Develop Block these parameters:
 +
 +  * **op** ​ =iframe (there are curently no other options)
 +  * **height** string of iframe height, optional
 +  * **ex** URL Encoded string with the URL to load in iframe. you can use the meta variables
 +    * $RECORD$ which will be changed to CRMID of the current record if it exists
 +    * $MODULE$ which will be changed to the MODULE NAME
 +
 +==== Developer Block Template ====
 +
 +This is the starting point of any developer block (the boilerplate).
 +
 +<code PHP>
 +<?php
 +/​*************************************************************************************************
 +** PUT YOUR LICENSE HERE **
 + ​*************************************************************************************************/​
 +require_once '​modules/​Vtiger/​DeveloperWidget.php';​
 +global $currentModule;​
 +
 +class YOURWIDGETNAMEHERE {
 + // Get class name of the object that will implement the widget functionality
 + public static function getWidget($name) {
 + return (new YOURWIDGETNAMEHERE_DetailViewBlock());​
 + }
 +}
 +
 +class YOURWIDGETNAMEHERE_DetailViewBlock extends DeveloperBlock {
 + // Implement widget functionality
 + private $widgetName = '​YOURWIDGETNAMEHERE';​
 +
 + // This one is called to get the contents to show on screen
 + public function process($context = false) {
 + global $adb;
 + $this->​context = $context;
 + $smarty = $this->​getViewer();​
 + *************
 + ALL YOU LOGIC GOES HERE
 + *************
 + return THE_HTML_YOU_WANT_TO_SHOW_INSIDE_THE_BLOCK;​
 + }
 +}
 +
 +if (isset($_REQUEST['​action'​]) && $_REQUEST['​action'​]==$currentModule.'​Ajax'​) {
 + $smq = new YOURWIDGETNAMEHERE_DetailViewBlock();​
 + echo $smq->​process($_REQUEST);​
 +}
 +</​code>​
 +
  
 ======How to add a special block to a module using templates====== ======How to add a special block to a module using templates======