GENWiki

Premier IT Outsourcing and Support Services within the UK

User Tools

Site Tools


joomla:obtain_a_list_of_new_articles_their_titles_and_url
    $db = JFactory::getDbo();
    $query = "SELECT id, title FROM #__content WHERE state=1 AND created > CURDATE()-1;";
    $db->setQuery($query);
    $rows = $db->loadObjectList();
 
    foreach($rows as $row) {
    	$id=$row->id;
    	$title=$row->title;
    	$url='https://www.gensupport.net/index.php?option=com_content&view=article&id='.$id;
    	echo "ID:".$id." [".$title."] -> ".$url."<br>";
    }

So in the snippet above we can see that we get all the articles from your Joomla site that were created yesterday onwards. You can change CURDATE()-1 to be just CURDATE() to get articles created today, or indeed change this to be something like (created >= CURDATE()-7 AND created < CURDATE()-1) to get a 6 day window and so on.

Once you have the query results, you can simply extract them as shown in the foreach loop. We only select id and title, but you can of course select anything you wish and access it as $row→field.

/data/webs/external/dokuwiki/data/pages/joomla/obtain_a_list_of_new_articles_their_titles_and_url.txt · Last modified: 2019/05/20 10:15 by genadmin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki