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: ^5.0
- drago-ex/component: ^4.0
- drago-ex/database: ^5.0
- drago-ex/datagrid: ^2.0
- drago-ex/form: ^4.0
- drago-ex/migration: ^1.0
- drago-ex/permission: ^2.0
- drago-ex/project-auth: ^2.0
- drago-ex/project-backend: ^1.0
- drago-ex/project-backend-ui: ^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/project-permission: Administration of custom roles and their privileges.
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
- MySQL or MariaDB
- 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. Set up what Assets lists and build the assets again (npm run vite:build).
Database
The migration creates the table static_page, empty:
php vendor/bin/migration db:migrate --packages
Pages are then written in the administration. bin/project-setup of Drago Project runs the migration for you.
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).
A page on the website is in the look of the module blog of compostrap
(the article and its content). Front UI already imports it; otherwise
import it in assets/front.scss:
@import 'compostrap/src/scss/blog';
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.