To create modal dialogs on dashboard single pages in packages, the following steps are necessary (assuming the package already exists):
Creating the following supplementary files / folders (for sake of readability):
/my_package/controllers/dialog/my_dialog.php
/my_package/views/dialogs/my_dialog.php
The 'my_dialog' controller should look like this:
namespace Concrete\Package\MyPackage\Controller\Dialog;
use Concrete\Core\Controller\Controller;
class MyDialog extends Controller
{
protected $viewPath = 'dialogs/my_dialog';
public function view()
{
/** your code */
}
}
The 'my_dialog' view is a standard Concrete5 view.
Add (if not exists) the following method inside the package controller:
public function on_start()
{
Route::register('/my_package/my_dialog',
'\Concrete\Package\MyPackage\Controller\Dialog\MyDialog::view');
}
Now in the single page view:
My dialog
$('a[data-button=add-event]').on('click', function() {
$.fn.dialog.open({
href: '',
title: 'My dialog',
width: '280',
height: '220',
modal: true
});
return false;
});
Loading Conversation