diff --git a/docs/en/events.md b/docs/en/events.md
index 1e65b63..ee014dd 100644
--- a/docs/en/events.md
+++ b/docs/en/events.md
@@ -101,4 +101,9 @@ the module can say no if there is no registrated account.
See the `Jelix\Authentication\LoginPass\AuthLPCanResetPasswordEvent` class.
+`ProfileViewPageEvent`
+----------------------
+This event is sent to extend the content of the "view profile" page.
+The view profile currently display information of the profile (username, first name, e-mail, ...) and a button to edit values.
+use `addContent(string $content, int $position)` to add some content to the page. Initial content is on position 5.
diff --git a/modules/account/controllers/profile.classic.php b/modules/account/controllers/profile.classic.php
index 98ca337..19ceba8 100644
--- a/modules/account/controllers/profile.classic.php
+++ b/modules/account/controllers/profile.classic.php
@@ -6,6 +6,7 @@
use Jelix\Authentication\Account\Manager;
use Jelix\Authentication\Account\Account;
+use Jelix\Authentication\Account\ProfileViewPageEvent;
class profileCtrl extends jController {
@@ -30,8 +31,12 @@ function index() {
$tpl = new \jTpl();
$tpl->assign('form', $form);
- $content = $tpl->fetch('profile_index');
- $rep->body->assign('MAIN', $content);
+ // ProfileViewPageEvent allowing to extend page content
+ $profileEvent = new ProfileViewPageEvent($tpl);
+ // add profile information view
+ $profileEvent->addContent($tpl->fetch('profile_index'), 5);
+ \jApp::services()->eventDispatcher()->dispatch($profileEvent);
+ $rep->body->assign('MAIN', $profileEvent->buildContent());
return $rep;
}
diff --git a/modules/account/lib/ProfileViewPageEvent.php b/modules/account/lib/ProfileViewPageEvent.php
new file mode 100644
index 0000000..a926d70
--- /dev/null
+++ b/modules/account/lib/ProfileViewPageEvent.php
@@ -0,0 +1,43 @@
+tpl = $tpl;
+ parent::__construct('ProfileViewPageEvent');
+ }
+
+ public function getTemplateService(): jTpl
+ {
+ return $this->tpl;
+ }
+
+ public function addContent($content, $order)
+ {
+ if(!isset($this->contentList[$order])) {
+ $this->contentList[$order] = [];
+ }
+ $this->contentList[$order][] = $content;
+ }
+
+ public function buildContent()
+ {
+ ksort($this->contentList);
+ $sortedContent = '';
+ foreach($this->contentList as $content) {
+ $sortedContent .= implode('', $content);
+ }
+ return $sortedContent;
+ }
+
+}
diff --git a/test/testapp/modules/test/events.xml b/test/testapp/modules/test/events.xml
index 02c704e..cf32ad7 100644
--- a/test/testapp/modules/test/events.xml
+++ b/test/testapp/modules/test/events.xml
@@ -3,4 +3,8 @@
+
+
+
+
diff --git a/test/testapp/modules/test/lib/ProfileEventListener.php b/test/testapp/modules/test/lib/ProfileEventListener.php
new file mode 100644
index 0000000..0db85f3
--- /dev/null
+++ b/test/testapp/modules/test/lib/ProfileEventListener.php
@@ -0,0 +1,21 @@
+getTemplateService();
+
+ $tpl->assign('position', 'above');
+ $event->addContent($tpl->fetch('test~profilePageExtended'), 6);
+ $tpl->assign('position', 'below');
+ $event->addContent($tpl->fetch('test~profilePageExtended'), 3);
+ $event->addContent('
content on same position use insertion order (1)', 8);
+ $event->addContent('
content on same position use insertion order (2)', 8);
+ }
+}
diff --git a/test/testapp/modules/test/templates/profilePageExtended.tpl b/test/testapp/modules/test/templates/profilePageExtended.tpl
new file mode 100644
index 0000000..5b60d80
--- /dev/null
+++ b/test/testapp/modules/test/templates/profilePageExtended.tpl
@@ -0,0 +1,2 @@
+
content will be displayed {$position} the form
+