[TikiWiki-commits] [Git][tikiwiki/tiki][30.x] [FIX] Fix meta keywords not showing when only tags are set
"Baraka Kinywa \(@bkinywa24\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <69e3f83a6d41f_3b4a8fd3c34332@gitlab-sidekiq-low-urgency-cpu-bound-v2-5cf6b587c7-x2mvd.mail> |
Baraka Kinywa pushed to branch 30.x at Tiki Wiki CMS Groupware / Tiki
Commits:
99625a81 by Espoir Baraka at 2026-04-19T00:24:27+03:00
[FIX] Fix meta keywords not showing when only tags are set
---
* [FIX] Fix meta keywords not showing when only tags are set
---
* [FIX] Fix meta keywords not showing when only tags are set
See merge request tikiwiki/tiki!9727
(cherry picked from commit a7bbad303d01461e505380cf457473c930256f30)
See merge request tikiwiki/tiki!10040
- - - - -
4 changed files:
- lib/freetag/freetaglib.php
- templates/header.tpl
- tiki-copypage.php
- tiki-setup.php
Changes:
=====================================
lib/freetag/freetaglib.php
=====================================
@@ -472,6 +472,29 @@ class FreetagLib extends ObjectLib
return ['data' => $ret, 'count' => $count];
}
+ /**
+ * Assign tags for the current object to Smarty as $tags.
+ *
+ * @throws UnexpectedValueException If the current section is not set yet.
+ */
+ public function assignCurrentObjectTagsToSmarty(): void
+ {
+ $section = \Tiki\Sections::getCurrentSection();
+ if (empty($section)) {
+ throw new \UnexpectedValueException('Current section is not set.');
+ }
+
+ $object = \Tiki\Sections::currentObject();
+ if (! $object) {
+ return;
+ }
+
+ $objectTags = $this->get_tags_on_object($object['object'], $object['type']);
+ $tags = $objectTags ? $objectTags['data'] : [];
+
+ TikiLib::lib('smarty')->assign('tags', $tags);
+ }
+
/**
*
*/
=====================================
templates/header.tpl
=====================================
@@ -59,6 +59,12 @@
<meta property="og:description" content="{if not empty($prefs.browsertitle_translated)}{$prefs.browsertitle_translated|tr_if|escape}{else}{$prefs.browsertitle|tr_if|escape}{/if}{if isset($title)} {$prefs.site_nav_seper} {$title}{/if}">
<meta name="twitter:description" content="{if not empty($prefs.browsertitle_translated)}{$prefs.browsertitle_translated|tr_if|escape}{else}{$prefs.browsertitle|tr_if|escape}{/if}{if isset($title)} {$prefs.site_nav_seper} {$title}{/if}">
{/if}
+{* --- Meta keywords: forum, per-page keywords, and/or tags (when "Include tags" is on) --- *}
+{if !empty($forum_info.name) and $prefs.metatag_threadtitle eq 'y'}
+ <meta name="keywords" content="{tr}Forum{/tr} {$forum_info.name|escape} {if !empty($thread_info.title)}{$thread_info.title|escape}{/if} {if $prefs.metatag_freetags eq 'y' and isset($tags) and !empty($tags)}{foreach from=$tags item=taginfo}{$taginfo.tag|escape} {/foreach}{/if}">
+{elseif !empty($metatag_local_keywords) or ($prefs.metatag_freetags eq 'y' and isset($tags) and !empty($tags))}
+ <meta name="keywords" content="{if $prefs.metatag_freetags eq 'y' and isset($tags) and !empty($tags)}{foreach from=$tags item="taginfo"}{$taginfo.tag|escape}, {/foreach}{/if}{if !empty($metatag_local_keywords)}{$metatag_local_keywords|escape}{/if}">
+{/if}
{if $prefs.site_google_analytics_site_ownership neq ''}
<meta name="google-site-verification" content="{$prefs.site_google_analytics_site_ownership|escape}">
{/if}
=====================================
tiki-copypage.php
=====================================
@@ -73,8 +73,9 @@ if (isset($_REQUEST["copy"]) || isset($_REQUEST["confirm"])) {
if (stristr($newName, $prefs['feature_wiki_userpage_prefix']) == $newName) {
Feedback::errorAndDie(tra("Cannot rename page because the new name begins with reserved prefix") . ' (' . $prefs['feature_wiki_userpage_prefix'] . ').', \Laminas\Http\Response::STATUS_CODE_409);
}
- $dupCateg = isset($_REQUEST['dupCateg']) && $_REQUEST['dupCateg'] === 'y';
- $dupTags = isset($_REQUEST['dupTags']) && $_REQUEST['dupTags'] === 'y';
+
+ $dupCateg = ! empty($_REQUEST['dupCateg']);
+ $dupTags = ! empty($_REQUEST['dupTags']);
$smarty->assign('newname', $newName);
$result = false;
=====================================
tiki-setup.php
=====================================
@@ -218,6 +218,14 @@ Sections::onSectionChange(function ($section) {
Language::setSectionLanguage();
});
+Sections::onSectionChange(function ($section) use ($prefs) {
+ if (($prefs['feature_freetags'] ?? 'n') !== 'y') {
+ return;
+ }
+
+ TikiLib::lib('freetag')->assignCurrentObjectTagsToSmarty();
+});
+
require_once('lib/setup/wiki.php');
$user_groups = $userlib->get_user_groups($user);
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/99625a8172ed9112cbccbe1cdaee95e710474231
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/99625a8172ed9112cbccbe1cdaee95e710474231
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs