Modal Popup

Modals are popup dialogs that appear in the middle of the screen while the rest of the screen becomes opaque, and can be created with the create modal CLI command, such as:

apex create modal <PACKAGE> <ALIAS>

apex create modal my-shop view-order

Using the above example, two new files named ViewOrder.php and ViewOrder.html will be created within the /src/MyShop/Opus/Modals/ directory. The PHP class contains two methods as described below.

Method Description
show() Executed when the modal is opened, and used to populate any necessary merge fields for the modal contents.
submit() Executed if and when the modal is submitted (eg. submit comment modal).

Place whatever you would like as the contents of the modal popup in the .html file that was created. It can contain merge fields as desired, which should then be assigned to the view via the show() method of the PHP class.

Display Modals on Web Pages

You may easily open a modal by linking to the openModal() Javascript function on any webpage such as:

<a href="javascript:openModal('<PACKAGE>/<ALIAS>');">Open modal</a>

If desired, you may include additional POST variables in the request by including a form string as the second argument, such as:

<a href="javascript;openModal('<PACKAGE>/<ALIAS>', 'key1=value1&key2=value2');">Open Modal</a>

The key1 and key2 variables will then be available as POST variables at $app->post('key1'), etc. Using the above created modal as an example, here's a link to open it:

<a href="javascript:openModal('my-shop/view-order', 'order_id=8831');">View Order</a>