Recent Topics

V2.4.6 "Post List" widget - order by title

Started by on Feb 09, 2009 – Contents updated: Feb 09, 2009

Feb 09, 2009 14:36    

Hi,

The Post List widget allows items to be ordered in one of three ways (newest to oldest, oldest to newest and random) which are all date based sort/orders. Is it possible to hack it so it orders by Title instead (either by ASC or DESC)?

Matthew

Feb 09, 2009 15:16

Hi Matthew,

In /inc/widgets/widgets/_coll_post_list.widget.php around line 70 (just before 'disp_order') place:

				'orderby' => array(
					'label' => T_( 'Order by' ),
					'note' => T_( 'Put something funny here.' ),
					'type' => 'select',
					'options' => array( 'datestart' => T_( 'Date' ), 'title' => T_( 'Title' ) ),
					'defaultvalue' => 'datestart'
				),


In the array 'disp_order' change this line to your liking:

'options' => array( 'DESC' => T_( 'Newest to oldest' ), 'ASC' => T_( 'Oldest to newest' ), 'RAND' => T_( 'Random selection' ) ),


like 'Newest to oldest' becomes 'Descending' or something..

Next open /inc/widgets/model/_widgets.class.php and add line 465 so it becomes:

		else
		{	// post list
			$ItemList->set_filters( array(
					'orderby' => ( $this->disp_params[ 'orderby' ] ? $this->disp_params[ 'orderby' ] : 'datestart' ), // <-- Add this line
					'order' => ( $this->disp_params[ 'disp_order' ] ? $this->disp_params[ 'disp_order' ] : 'DESC' ),
					'unit' => 'posts',						// We want to advertise all items (not just a page or a day)
				) );
		}

(tested)

Good luck

lxsparks Feb 11, 2009 22:02

lxsparks

Hi Afwas,

Thank you! :D That worked a treat, I had been poking looking for it all happened but all to no avail.

Thanks again!

Matthew

Feb 11, 2009 22:12

You're welcome.
Editing core widgets is difficult indeed.

Have fun


Form is loading...

Content Mangement System – This forum is powered by b2evolution CMS, a complete engine for your website.