Forums  ›  Developers  ›  Developer Notices
 

New advMsgBox Function

Thanks Deano, I can see where this new Message Box will be useful.  Since language keys can also be populated with Data this can be very useful.

It can contain html. Most of the time a language key will be used for the text, and the language key can contain html, so the message will also.

Can the text contain HTML markup or will it just render the HTML markup as text?

Developer Notice.

While fixing a bug in the page builders in admin i ran into a situation where i needed a msgBox that could be manually closed. This function was created to solve that need, but i also went a little further with it than what i needed so it could do a lot more.

This new function will be available in the next version of Cheetah.

This is the info on the new function.

    /**
    * Function will generate an advanced Message Box. ;
    *
    * @param          : $sText (string) Text to display in the message box. (Required) ;
    * @param          : $aOptions (array) Array of additional options to pass to function. (Optional) ;
    *
    * All params in the $aOptions array are optional. Below is the option arrays defaults.
    *
    * $aOptions = array(
    *   'timer' => 0,   // Time in seconds before box is closed automatically.
    *   'onTimer' => '',  // Javascript function to be called when close timer expires.
    *   'showclosebtn' => false,  // Show a close button at the bottom of the message box.
    *   'removefog' => false, // Remove background fog when clicking the close button.
    *   'class' => 'msgbox_content ch-def-font-large',  // Class to use for the message box.
    *   'buttonclass' => 'ch-btn',  // Class to use for the message box close button.
    *   'showtitle' => false, // Show a title on the message box.
    *   'showtitleclose' => false,  // Show a close X in the message box title area.
    *   'titletext' => '',  // The text to display for the title.
    *   'titleclass' => 'MsgBoxTitle',  // Class to use for the title.
    *   'showicon' => false,  // So a icon to the left of the message.
    *   'icon' => 'info-circle',  // The icon to display.
    *   'iconclass' => 'sys-icon icon-large', // The class to use for the icon.
    * );
    */
    function advMsgBox($sText, $aOptions = array())

 

Below are examples of how to use it, and a photo of the result.

Example 1:  (Default options)

advMsgBox('This block has no properties');

 

 

Example 2: (With title)

$aOptions = array(
  'showtitle' => true,
  'titletext' => 'Info!',
);
advMsgBox('This block has no properties', $aOptions);

 

Example 3: (With title and close X in title)

$aOptions = array(
  'showtitle' => true,
  'titletext' => 'Info!',
  'showtitleclose' => true,
);
advMsgBox('This block has no properties', $aOptions);

 

 

Example 4: (With title and close X in title and a close button)

$aOptions = array(
  'showtitle' => true,
  'titletext' => 'Info!',
  'showtitleclose' => true,
  'showclosebtn' => true,
);
advMsgBox('This block has no properties', $aOptions);

 

 

Example 5: (With title and close X in title and a close button and icon)

$aOptions = array(
  'showtitle' => true,
  'titletext' => 'Info!',
  'showtitleclose' => true,
  'showclosebtn' => true,
  'showicon' => true,
);
advMsgBox('This block has no properties', $aOptions);

 

 

The next examples are the same as Example 5 but with one of the 4 built in colors.

Example 6:

$aOptions = array(
  'showtitle' => true,
  'titletext' => 'Alert!',
  'showtitleclose' => true,
  'showclosebtn' => true,
  'showicon' => true,
  'icon' => 'exclamation-triangle',
  'class' => 'MsgBoxAlert ch-def-font-large',
  'titleclass' => 'MsgBoxTitleAlert ch-def-font-large',
);
advMsgBox('This block has no properties', $aOptions);



Example 7:

$aOptions = array(
  'showtitle' => true,
  'titletext' => 'Warning!',
  'showtitleclose' => true,
  'showclosebtn' => true,
  'showicon' => true,
  'icon' => 'exclamation-triangle',
  'class' => 'MsgBoxWarning ch-def-font-large',
  'titleclass' => 'MsgBoxTitleWarning ch-def-font-large',
);
advMsgBox('This block has no properties', $aOptions);

 

 

Example 8:

$aOptions = array(
  'showtitle' => true,
  'titletext' => 'Info!',
  'showtitleclose' => true,
  'showclosebtn' => true,
  'showicon' => true,
  'icon' => 'info-circle',
  'class' => 'MsgBoxInfo ch-def-font-large',
  'titleclass' => 'MsgBoxTitleInfo ch-def-font-large',
);
advMsgBox('This block has no properties', $aOptions);



Example 9:

$aOptions = array(
  'showtitle' => true,
  'titletext' => 'Success!',
  'showtitleclose' => true,
  'showclosebtn' => true,
  'showicon' => true,
  'icon' => 'check',
  'class' => 'MsgBoxSuccess ch-def-font-large',
  'titleclass' => 'MsgBoxTitleSuccess ch-def-font-large',
);
advMsgBox('This block has no properties', $aOptions);

 

 

Given you can pass your own class to the message box, title, icon and button, the number of combinations you can dream up could be endless.

For any messages that are simple and don't require a title or close button such as the first example, please use the normal msgBox function. This advMsgBox function should only be used when these extra options are needed.

1.png4.8K25 views
2.png5.7K25 views
3.png5.9K25 views
4.png8.1K25 views
5.png8.4K25 views
6.png10.3K25 views
7.png9.7K25 views
8.png10K25 views
9.png10K25 views