Skip to content

Commit d62e738

Browse files
committed
Banner mdoule: get article keeywords form article
1 parent 1c0ac3d commit d62e738

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

modules/mod_banners/src/Helper/BannersHelper.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,23 @@ public function getBanners(Registry $params, CMSApplication $app)
4242
/** @var BannersModel $model */
4343
$model = $app->bootComponent('com_banners')->getMVCFactory()->createModel('Banners', 'Site', ['ignore_request' => true]);
4444

45-
$keywords = explode(',', $app->getDocument()->getMetaData('keywords'));
45+
$input = $app->input;
46+
$keywords = [];
47+
48+
// Check if the current view is an article
49+
if ($input->getCmd('option') === 'com_content' && $input->getCmd('view') === 'article') {
50+
$articleId = $input->getInt('id');
51+
52+
if (\is_integer($articleId)) {
53+
54+
// Load the article model to get the keywords
55+
$contentModel = $app->bootComponent('com_content')->getMVCFactory()->createModel('Article', 'Site', ['ignore_request' => true]);
56+
57+
$article = $contentModel->getItem($articleId);
58+
$keywords = explode(',', $article->metakey);
59+
}
60+
}
61+
4662
$config = ComponentHelper::getParams('com_banners');
4763

4864
$model->setState('filter.client_id', (int) $params->get('cid'));

0 commit comments

Comments
 (0)