drago-ex / project-static-page
Static page administration for Drago Project.
Package info
github.com/drago-ex/project-static-page
Type:drago-tools-resource
pkg:composer/drago-ex/project-static-page
Requires
- php: >=8.3 <9
- drago-ex/application: ^4.0
- drago-ex/component: ^3.0
- drago-ex/database: ^5.0
- drago-ex/datagrid: ^1.0
- drago-ex/form: ^3.0
- drago-ex/migration: ^1.0
- drago-ex/project-auth: ^2.0
- drago-ex/project-backend: ^1.0
- drago-ex/texy-toolbar: ^1.0
- drago-ex/translator: ^4.0.1
- drago-ex/utils: ^2.0
- nette/application: ^3.2
- nette/caching: ^3.3
- nette/di: ^3.2
Requires (Dev)
- drago-ex/project-tools: ^1.0
- nette/tester: ^2.5
- phpstan/phpstan-nette: ^2.0
Suggests
- drago-ex/permission: Generates the access rules of the page administration and the pages (bin/create-page-permission).
- drago-ex/project-backend-ui: Administration layout; the page administration uses its content widget.
- drago-ex/project-permission: Role and permission management in the administration, which registers the generated providers.
Provides
None
Conflicts
None
Replaces
None
README
Static pages for Drago Project: pages such as "About us" with their own address and an optional item in the website menu, written in the administration.
Requirements
- PHP >= 8.3, < 9
- Drago Project
Installation
composer require drago-ex/project-static-page
Project Tools copies the files of the package into the project, where you adapt them.
Database
The migration creates the table static_page; run it with bin/project-setup of Drago Project or
php vendor/bin/migration db:migrate --packages.
Assets
The package has no scripts of its own. It uses:
- drago-ex/datagrid: the list of pages, set up in
admin.jsandadmin.scss. - drago-ex/texy-toolbar: the toolbar of the content field (
admin.js) and the copy button of code blocks (front.js).
Administration
{link :Backend:Page:}
The menu item comes from Backend/Page/5.menu.neon with
Backend UI. Pages are created, edited, deleted, filtered and
sorted in a datagrid. A page has a title, content, slug, meta description, status (draft or published) and
"Show in the menu" with its position. A slug whose address already belongs to another page of the site (admin,
sign, en…) is refused.
Website
A published page is shown at the top level of the site, e.g. /o-nas (and /en/o-nas). The route is added by
Front/Page/8.conf.neon before the front router and matches only slugs of published pages.
{link :Front:Page: slug: 'o-nas'}
Content is written in Texy and printed safely: raw HTML is limited to safe tags and
links, headings start at <h2> and code blocks with a language are highlighted. The description is the
<meta name="description"> of the page.
Pages with "Show in the menu" are returned by App\Model\Page\PageMenu::getItems() (slug => title, cached,
cleaned when a page is saved or deleted). Print them in your layout
(Front UI does it in its navbar):
$this->template->menuPages = $this->pageMenu->getItems();
<a n:foreach="$menuPages as $slug => $title" n:href=":Front:Page:default, slug: $slug">{$title}</a>
Permissions
The rules are in Backend/Page/acl.neon (resource Backend:Page, the administrator only) and
Front/Page/acl.neon (resource Front:Page, everyone). The privileges of Backend:Page are default, edit
and delete; buttons are shown only to those who may use them.
Project Permission gives them to other roles.
The same files describe the privileges (permissionLabels) for the permissions page of Project Permission.