If you want to create a custom functionality in your Joomla site related to the articles and you have to get the article details by using article ID, then keep your close attention in this post as I am going share how to get the article by article ID in Joomla 3.
Copy the below code snippet and use it in any Joomla template file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <?php /* * Get article by article ID */ //db connection $db = &JFactory::getDBO(); $sql = "SELECT introtext FROM #__content WHERE id = ".intval($articleId); $db->setQuery($sql); $fullArticle = $db->loadResult(); if(!strlen(trim($fullArticle))){ $fullArticle = "Article is empty"; } ?> |
Liked this program? Do Like & share with your friends.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: article ID in Joomla, get article by article ID, get article details by ID, Joomla articles, joomla tutorials, Joonla article tutorial