Skip to content

Commit

Permalink
Add page meta title and meta description
Browse files Browse the repository at this point in the history
  • Loading branch information
HansSchouten committed Jan 25, 2023
1 parent f7bea1d commit e95c819
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
2 changes: 2 additions & 0 deletions config/create-tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ CREATE TABLE `page_translations` (
`page_id` int(11) NOT NULL,
`locale` VARCHAR(50) NOT NULL,
`title` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`meta_title` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`meta_description` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`route` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
Expand Down
4 changes: 3 additions & 1 deletion lang/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
'pages' => 'Pages',
'menus' => 'Menus',
'name' => 'Name',
'page-title' => 'Page title',
'page-title' => 'Menu title',
'page-meta-title' => 'Page meta title',
'page-meta-description' => 'Page meta description',
'route' => 'URL',
'layout' => 'Layout',
'actions' => 'Actions',
Expand Down
4 changes: 3 additions & 1 deletion lang/es.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
'pages' => 'Páginas',
'menus' => 'Menús',
'name' => 'Nombre',
'page-title' => 'Título de la Página',
'page-title' => 'Título de la página del menú',
'page-meta-title' => 'Metatítulo de la página',
'page-meta-description' => 'Meta descripción de la página',
'route' => 'URL',
'layout' => 'Diseño',
'actions' => 'Acciones',
Expand Down
4 changes: 3 additions & 1 deletion lang/nl.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
'pages' => 'Pagina\'s',
'menus' => 'Menus',
'name' => 'Naam',
'page-title' => 'Pagina titel',
'page-title' => 'Menu titel',
'page-meta-title' => 'Pagina (meta) titel',
'page-meta-description' => 'Pagina meta omschrijving',
'route' => 'URL',
'layout' => 'Paginaopbouw',
'actions' => 'Acties',
Expand Down
10 changes: 10 additions & 0 deletions src/Modules/WebsiteManager/resources/views/page-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@
<input type="text" class="form-control" id="page-title" name="title[<?= phpb_e($languageCode) ?>]" value="<?= phpb_e($pageTranslations[$languageCode]['title'] ?? '') ?>" required>
</div>

<div class="form-group">
<label for="page-meta-title"><?= phpb_trans('website-manager.page-meta-title') ?></label>
<input type="text" class="form-control" id="page-meta-title" name="meta_title[<?= e($languageCode) ?>]" value="<?= e($pageTranslations[$languageCode]['meta_title'] ?? '') ?>">
</div>

<div class="form-group">
<label for="page-meta-description"><?= phpb_trans('website-manager.page-meta-description') ?></label>
<input type="text" class="form-control" id="page-meta-description" name="meta_description[<?= e($languageCode) ?>]" value="<?= e($pageTranslations[$languageCode]['meta_description'] ?? '') ?>">
</div>

<div class="form-group required">
<label for="route"><?= phpb_trans('website-manager.route') ?></label>
<input type="text" class="form-control" id="route" name="route[<?= phpb_e($languageCode) ?>]" value="<?= phpb_e($pageTranslations[$languageCode]['route'] ?? '') ?>" required>
Expand Down
4 changes: 3 additions & 1 deletion src/Repositories/PageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function update($page, array $data)
protected function replaceTranslations(PageContract $page, array $data)
{
$activeLanguages = phpb_active_languages();
foreach (['title', 'route'] as $field) {
foreach (['title', 'meta_title', 'meta_description', 'route'] as $field) {
foreach ($activeLanguages as $languageCode => $languageTranslation) {
if (! isset($data[$field][$languageCode])) {
return false;
Expand All @@ -106,6 +106,8 @@ protected function replaceTranslations(PageContract $page, array $data)
phpb_config('page.translation.foreign_key') => $page->getId(),
'locale' => $languageCode,
'title' => $data['title'][$languageCode],
'meta_title' => $data['meta_title'][$languageCode],
'meta_description' => $data['meta_description'][$languageCode],
'route' => $data['route'][$languageCode],
]);
}
Expand Down

0 comments on commit e95c819

Please sign in to comment.