web-dev-qa-db-fra.com

Afficher la note de version sur les articles

Comment puis-je afficher une version-note d'un article sur le front-end - comme les balises de date ou auteur?

Voici un guide rapide sur la façon de le faire:

/* First include the path */
JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_contenthistory', 'ContenthistoryModel');

/* Now instantiate the model */
$historyModel = JModelLegacy::getInstance('History', 'ContenthistoryModel');

/* Now get the content history of the current article */
$items = $historyModel->getItems();

/* Now get the last item. Note that depending on the ordering, you may need to get the first item */
$lastItem = array_pop($items);

/* Now you can get the latest note */
$latestNote = $lastItem->version_note;

Notez que je n'ai pas testé le code ci-dessus, mais techniquement, cela devrait fonctionner.

1
itoctopus