1

I can only retrieve the global keywords. Is there a way to retrieve the article's keywords?

I am trying to modify the Administrator template. I want to add each article's keywords to the Articles view page located at (Administrator template: html/com_content/articles/default.php).

Thank you.

<?php
    $document = JFactory::getDocument();
    $content = $document->getMetaData('keywords');
    echo $content;
    ?> 
2
  • It's confusing what you are trying to do. Administrator template, each article keywords to the articles view page ... ?
    – FFrewin
    Nov 15 '16 at 13:23
  • The page I want to modify can be found at: Administrator Main Menu - > Content - > Articles. This page lists all the articles. I want to display the keywords for each article the same way the Category is listed.
    – Donald Ax
    Nov 15 '16 at 15:45
1

I finally got it by accessing the database correctly. Here is the code:

<?php
//get metakey by id
$db = JFactory::getDbo();
$id = $item->id;
$db->setQuery("SELECT metakey FROM #__content WHERE id='$id'");
$metakey = $db->loadResult();
echo $metakey;
?> 
0

Well, I would look for the possibility of overriding the articles model to add in the query the metakey column and then call $item->metakey in the articles view template, instead of generating db queries for each of the loaded articles.

Actually, because this is a sligth modification, I could even consider to simply do it directly on the core model file and have to maintain this with every update - although not the recommended practice, I might be willing to pay the tribute for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.