Working function of php 7.4 not working in 8.0 in joomla 3.10

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
mch79
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Wed Jul 22, 2015 7:25 am

Working function of php 7.4 not working in 8.0 in joomla 3.10

Post by mch79 » Sat Nov 26, 2022 2:18 am

Am displaying list of news haviing
Date

News Heading

Short Descrption
The list is spread to around 100 pages, having 20 news in each page

Issue is: This is working absolute fine in php 7.4.x in joomla 3.10 where on clicking url - list is shown spread over multiple pages having sort by date wise as first criteria, latest date of publishing is coming

But when same used on php 8.0.x - its showing incorrectly, where on clicking URL - last page of list having page number 100 is shown first. Now when i add on limitstart=0 in url then its showing correctly as the first page.

Below is code of views/list/tmpl/default.php

Code: Select all

if(count($this->items) >0){
    //$i=1;
    
    foreach($this->items as $newslist)
    {
        $date = JFactory::getDate($newslist->n_date);
        $list .='<h3><strong>'.$newslist->v_heading.'</strong></h3>
        <p>'. $date->format('F j, Y').'</p>
        <p>'.substr($newslist->v_short_description,0,100).'</p>
        <p><i>Know More on:- </i><a href="index.php?option=com_news&view=detail&v_id='.$newslist->id.'&Itemid='.$Itemid.'"><b><i>'.$newslist->v_heading.'</i></b></a></p><hr/><br>';
                
        //$i=$i+1;
    }
}else{
        JError::raiseError(404, "Message");
    
}
and echoning it

Code: Select all

<?php echo $list?>


and for models/list.php this is the function

Code: Select all

protected function getListQuery()
	{
		// Create a new query object.
		$db    = $this->getDbo();
		$query = $db->getQuery(true);
		// Select the required fields from the table.
		$query
			->select(
				$this->getState(
					'list.select', 'DISTINCT a.*'
				)
			);

		$query->from('`#__news` AS a');
				
		if (!JFactory::getUser()->authorise('core.edit', 'com_news'))
		{
			$query->where('a.state = 1');
		}

		// Filter by search in title
		$search = $this->getState('filter.search');

		if (!empty($search))
		{
			if (stripos($search, 'id:') === 0)
			{
				$query->where('a.id = ' . (int) substr($search, 3));
			}
			else
			{
				$search = $db->Quote('%' . $db->escape($search, true) . '%');
				$query->where('( a.n_heading LIKE ' . $search . ' )');
			}
		}
		
/*
		// Add the list ordering clause.
		$orderCol  = $this->state->get('list.ordering');
		$orderDirn = $this->state->get('list.direction');

		if ($orderCol && $orderDirn)
		{
			$query->order($db->escape($orderCol . ' ' . $orderDirn));
		}
*/		//Order by date
		
		$query->order ('a.n_date DESC');
		$query->order ('a.id DESC');
		
		return $query;
	}
Unsure how to achieve in and why its not working in php 8.0 where Date wise should be shown on clicking url.

Locked

Return to “Joomla! 3.x Coding”