Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
modal_page
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
14
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
modal_page
Merge requests
!35
Update README.md
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Update README.md
issue/modal_page-3344242:3344242-update-the-readme.md
into
5.0.x
Overview
0
Commits
2
Pipelines
2
Changes
1
Merged
Rinku Jacob
requested to merge
issue/modal_page-3344242:3344242-update-the-readme.md
into
5.0.x
1 year ago
Overview
0
Commits
2
Pipelines
2
Changes
1
Expand
👍
0
👎
0
Merge request reports
Compare
5.0.x
version 2
e438e89e
1 year ago
version 1
6fec2934
1 year ago
5.0.x (base)
and
latest version
latest version
87449445
2 commits,
1 year ago
version 2
e438e89e
2 commits,
1 year ago
version 1
6fec2934
1 commit,
1 year ago
1 file
+
73
−
89
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
README.md
+
73
−
89
Options
# MODAL PAGE
## CONTENTS OF THIS FILE
*
Introduction
*
Requirements
*
Installation
*
Configuration
*
Hooks and Modal programatically
*
Maintainers
## INTRODUCTION
# Modal Page
The Modal project allows you to create Modal using CMS only.
@@ -19,111 +6,108 @@ You can place your Modal in specific page and configure if it'll appear when
the end-user open the page (auto-open on page load) or if this Modal will appear
when the user click in specific class or ID on HTML.
*
For a full description of the
project
, visit the
project page:
https://www.drupal.org/project/modal_page
For a full description of the
module
, visit the
[
project page
](
https://www.drupal.org/project/modal_page
)
.
*
To s
ubmit bug reports and feature suggestions, or track changes
:
https://www.drupal.org/project/issues/modal_page
S
ubmit bug reports and feature suggestions, or track changes
in the
[
issue queue
](
https://www.drupal.org/project/issues/modal_page
)
.
## REQUIREMENTS
No special requirem
ents
.
## Table of cont
ents
-
Requirements
-
Installation
-
Configuration
-
Hooks and Modal Programmatically
-
Maintainers
## INSTALLATION
*
Install as you would normally. Visit
https://www.drupal.org/docs/8/extending-drupal-8/installing-drupal-8-modules
for further information.
## Requirements
No special requirements.
## CONFIGURATION
*
Configure your messages in Administration » Structure » Modal
## Installation
Click in Add Modal
Install as you would normally install a contributed Drupal module. For further
information, see
[
Installing Drupal Modules
](
https://www.drupal.org/docs/extending-drupal/installing-drupal-modules
)
.
1.
Set the Title of modal;
2.
Set the Text of modal (Body);
4.
Set pages to show the Modal;
6.
Select if it'll appear on page load or in element click;
7.
Use extra configuration in vertical tab (left side);
7.
Save.
##
HOOKS AND MODAL PROGRAMATICALLY
##
Configuration
*
You can insert your Modal programatically using entityTypeManager like this:
1.
Configure your messages in Administration » Structure » Modal
2.
Click in Add Modal
3.
Set the Title of modal;
4.
Set the Text of modal (Body);
5.
Set pages to show the Modal;
6.
Select if it'll appear on page load or in element click;
7.
Use extra configuration in vertical tab (left side);
8.
Save.
```
$modal = \Drupal::entityTypeManager()->getStorage('modal')->create();
$modal->setId('modal_id');
$modal->setLabel('Modal Title');
$modal->setBody('Modal Content');
$modal->setPages('/hello');
$modal->save();
```
## Hooks and Modal Programmatically
*
You can
change Modals before display with these hooks
1.
You can
insert your Modal programatically using entityTypeManager like this:
-
HOOK_modal_alter(&$modal, $modal_id)
```
$modal = \Drupal::entityTypeManager()->getStorage('modal')->create();
Example:
$modal->setId('modal_id');
$modal->setLabel('Modal Title');
$modal->setBody('Modal Content');
$modal->setPages('/hello');
$modal->save();
```
```
/**
* Implements hook_modal_alter().
*/
function PROJECT_modal_alter(&$modal, $modal_id) {
$modal->setLabel('Title Updated');
$modal->setBody('Body Updated');
}
```
2.
You can change Modals before display with these hooks
-
HOOK_modal_
ID_
alter(&$modal, $modal_id)
-
HOOK_modal_alter(&$modal, $modal_id)
Example:
Example:
```
/**
* Implements hook_modal_
ID_
alter().
*/
function PROJECT_modal_
ID_
alter(&$modal, $modal_id) {
$modal->setLabel('
New
Title');
$modal->setBody('
New
Body');
}
```
```
/**
* Implements hook_modal_alter().
*/
function PROJECT_modal_alter(&$modal, $modal_id) {
$modal->setLabel('Title
Updated
');
$modal->setBody('Body
Updated
');
}
```
-
HOOK_modal_
submit
(&$modal, $modal_id)
-
HOOK_modal_
ID_alter
(&$modal, $modal_id)
Example:
Example:
```
/**
* Implements hook_modal_submit().
*/
function PROJECT_modal_submit($modal, $modal_state, $modal_id) {
```
/**
* Implements hook_modal_ID_alter().
*/
function PROJECT_modal_ID_alter(&$modal, $modal_id) {
$modal->setLabel('New Title');
$modal->setBody('New Body');
}
```
// Your AJAX here.
\Drupal::logger('modal_page')->notice('Modal Submit was triggered');
-
HOOK_modal_submit(&$modal, $modal_id)
}
```
Example:
## TESTS
```
/**
* Implements hook_modal_submit().
*/
function PROJECT_modal_submit($modal, $modal_state, $modal_id) {
*
Before of run tests you needs create a shortcut for core/phpunit.xml.dist in
your root project.
// Your AJAX here.
\Drupal::logger('modal_page')->notice('Modal Submit was triggered');
### EXECUTING UNITTESTS
}
```
vendor/bin/phpunit modules/contrib/modal_page
```
## M
AINTAINERS
## M
aintainers
### Current maintainers:
*
Renato Gonçalves (RenatoG) - https://www.drupal.org/user/3326031
*
Thalles Ferreira (thalles) - https://www.drupal.org/user/3589086
*
Paulo Henrique Cota Starling (paulocs) - https://www.drupal.org/user/3640109
-
Renato Gonçalves -
[
RenatoG
](
https://www.drupal.org/user/3326031
)
-
Thalles Ferreira -
[
thalles
](
https://www.drupal.org/user/3589086
)
-
Paulo Henrique Cota Starling -
[
paulocs
](
https://www.drupal.org/user/3640109
)
Loading