[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Fix meta keywords not showing when only tags are set

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69e2595b18f4d_3b18df0877675@gitlab-sidekiq-low-urgency-cpu-bound-v2-758bd58cf4-jfrq6.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
a7bbad30 by Espoir Baraka at 2026-04-17T15:34:42+00:00
[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

- - - - -


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/a7bbad303d01461e505380cf457473c930256f30

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/a7bbad303d01461e505380cf457473c930256f30
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.