diff options
| author | Greg Roach <fisharebest@webtrees.net> | 2019-05-01 09:37:28 +0100 |
|---|---|---|
| committer | Greg Roach <fisharebest@webtrees.net> | 2019-05-01 09:37:28 +0100 |
| commit | 678a16c4edfbf3cd21bd4224ccc5fb41c0dc72f0 (patch) | |
| tree | b3b6c14eda703dbf1e88c58e4acb401705c746bf /modules_v4 | |
| parent | f7fac2396eeb0985549aeb41de012f1ed65efc4b (diff) | |
| download | webtrees-678a16c4edfbf3cd21bd4224ccc5fb41c0dc72f0.tar.gz webtrees-678a16c4edfbf3cd21bd4224ccc5fb41c0dc72f0.tar.bz2 webtrees-678a16c4edfbf3cd21bd4224ccc5fb41c0dc72f0.zip | |
Add example footer module
Diffstat (limited to 'modules_v4')
3 files changed, 83 insertions, 0 deletions
diff --git a/modules_v4/example-footer.disable/module.php b/modules_v4/example-footer.disable/module.php new file mode 100644 index 0000000000..5225398208 --- /dev/null +++ b/modules_v4/example-footer.disable/module.php @@ -0,0 +1,76 @@ +<?php + +namespace MyCustomNamespace; + +use Fisharebest\Webtrees\Module\AbstractModule; +use Fisharebest\Webtrees\Module\ModuleCustomInterface; +use Fisharebest\Webtrees\Module\ModuleCustomTrait; +use Fisharebest\Webtrees\Module\ModuleFooterInterface; +use Fisharebest\Webtrees\Module\ModuleFooterTrait; +use Fisharebest\Webtrees\Tree; +use Fisharebest\Webtrees\View; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; + +/** + * Example footer with a link to a page of information. + */ +return new class extends AbstractModule implements ModuleCustomInterface, ModuleFooterInterface { + use ModuleCustomTrait; + use ModuleFooterTrait; + + /** + * @return string + */ + public function title(): string + { + return 'Custom footer'; + } + + /** + * Bootstrap the module + */ + public function boot(): void + { + // Register a namespace for our views. + View::registerNamespace($this->name(), $this->resourcesFolder() . 'views/'); + } + + /** + * Where does this module store its resources + * + * @return string + */ + public function resourcesFolder(): string + { + return __DIR__ . '/resources/'; + } + + /** + * A footer, to be added at the bottom of every page. + * + * @param Tree|null $tree + * + * @return string + */ + public function getFooter(?Tree $tree): string + { + $url = route('module', ['module' => $this->name(), 'action' => 'Page']); + + return view($this->name() . '::footer', ['url' => $url]); + } + + /** + * Generate the page that will be shown when we click the link in the footer. + * + * @param ServerRequestInterface $request + * + * @return ResponseInterface + */ + public function getPageAction(ServerRequestInterface $request): ResponseInterface + { + return $this->viewResponse($this->name() . '::page', [ + 'title' => $this->title(), + ]); + } +}; diff --git a/modules_v4/example-footer.disable/resources/views/footer.phtml b/modules_v4/example-footer.disable/resources/views/footer.phtml new file mode 100644 index 0000000000..f553598505 --- /dev/null +++ b/modules_v4/example-footer.disable/resources/views/footer.phtml @@ -0,0 +1,4 @@ +<div class="wt-footer wt-footer-custom text-center py-2"> + Click <a href="<?= e($url) ?>">here</a> for more information. +</div> + diff --git a/modules_v4/example-footer.disable/resources/views/page.phtml b/modules_v4/example-footer.disable/resources/views/page.phtml new file mode 100644 index 0000000000..872336957f --- /dev/null +++ b/modules_v4/example-footer.disable/resources/views/page.phtml @@ -0,0 +1,3 @@ +<h2><?= e($title) ?></h2> + +<p>Be nice to fish!</p> |
