Next and Previous AD

Please post bugs you have found in tuffclassified theme. If you have fix for that post it too.
Do not post anything else, issue related to third party plugins should not be posted here.
Locked
renas
Starter
Posts: 30
Joined: Sun Jun 14, 2015 5:33 pm

Next and Previous AD

Post by renas »

Hi,

This doesn't work on my site.

http://www.classificadosgratis.biz/

Tks
Rendy
Starter
Posts: 36
Joined: Sun Sep 22, 2013 8:36 am

Re: Next and Previous AD

Post by Rendy »

Hi renas open this link to fix ur trouble
http://forum.tuffindia.com/viewtopic.ph ... +ads#p1696
Regards
renas
Starter
Posts: 30
Joined: Sun Jun 14, 2015 5:33 pm

Re: Next and Previous AD

Post by renas »

Tks Rendy,

That solved the problem even so i will post an improvement to this ASAP. :)
renas
Starter
Posts: 30
Joined: Sun Jun 14, 2015 5:33 pm

Re: Next and Previous AD

Post by renas »

Hi,

I have this query from an old template wich i could reuse on this one. Even so i do think that can be improved and well adapted to this great theme.

The structure have some basic format.

1. Saves when possible the order column and direction. If not uses default.
2. Uses Category, Region, City, Price Min and Max. I don't have Country as i use only one.

The code:

Code: Select all

		if( empty($_SESSION['vOrder'])){
			$_SESSION['vOrder'] = osc_default_order_field_at_search();
		}
		
		if( empty($_SESSION['vOrderType'])){
			$_SESSION["vOrderType"] = osc_default_order_type_at_search();
		}
		
		if($_SESSION['vOrder'] == "dt_pub_date"){
			$order_item = osc_item_pub_date();
		} else {
			$order_item = osc_item_price();
		}
	
		$mSearch = new Search();
		$mSearch->addCategory($_SESSION["vCategory"]);
		$mSearch->addRegion($_SESSION["vRegion"]);
		$mSearch->addCity($_SESSION["vCity"]);
		$mSearch->priceRange($_SESSION["vPriceMin"],$_SESSION["vPriceMax"]);
		if($_SESSION["vOrderType"] == "asc"){
			$mSearch->addItemConditions(sprintf("%st_item.".$_SESSION['vOrder']." <= '%s' ", DB_TABLE_PREFIX, $order_item));
			$mSearch->dao->where('('.sprintf("%st_item.pk_i_id < %s ", DB_TABLE_PREFIX, osc_item_id()).' || '.sprintf("%st_item.".$_SESSION['vOrder']." < '%s' ", DB_TABLE_PREFIX, $order_item).' )');
			$mSearch->order(sprintf("%st_item.".$_SESSION['vOrder'], DB_TABLE_PREFIX), "DESC");
		} else{
			$mSearch->addItemConditions(sprintf("%st_item.".$_SESSION['vOrder']." >= '%s' ", DB_TABLE_PREFIX, $order_item));
			$mSearch->dao->where('('.sprintf("%st_item.pk_i_id > %s ", DB_TABLE_PREFIX, osc_item_id()).' || '.sprintf("%st_item.".$_SESSION['vOrder']." > '%s' ", DB_TABLE_PREFIX, $order_item).' )');
			$mSearch->order(sprintf("%st_item.".$_SESSION['vOrder'], DB_TABLE_PREFIX), "ASC");
		}
		$mSearch->limit('0', '1');
Any help on how to adapt to Tufftheme will be great.

At this point i can identify that in listing page in search we have, already category, region and city. But not the remaining values.

:mrgreen:
User avatar
tuffadmin
Site Admin
Posts: 1236
Joined: Tue Jan 29, 2013 7:31 pm

Re: Next and Previous AD

Post by tuffadmin »

renas wrote:Hi,

I have this query from an old template wich i could reuse on this one. Even so i do think that can be improved and well adapted to this great theme.

The structure have some basic format.

1. Saves when possible the order column and direction. If not uses default.
2. Uses Category, Region, City, Price Min and Max. I don't have Country as i use only one.

The code:

Code: Select all

		if( empty($_SESSION['vOrder'])){
			$_SESSION['vOrder'] = osc_default_order_field_at_search();
		}
		
		if( empty($_SESSION['vOrderType'])){
			$_SESSION["vOrderType"] = osc_default_order_type_at_search();
		}
		
		if($_SESSION['vOrder'] == "dt_pub_date"){
			$order_item = osc_item_pub_date();
		} else {
			$order_item = osc_item_price();
		}
	
		$mSearch = new Search();
		$mSearch->addCategory($_SESSION["vCategory"]);
		$mSearch->addRegion($_SESSION["vRegion"]);
		$mSearch->addCity($_SESSION["vCity"]);
		$mSearch->priceRange($_SESSION["vPriceMin"],$_SESSION["vPriceMax"]);
		if($_SESSION["vOrderType"] == "asc"){
			$mSearch->addItemConditions(sprintf("%st_item.".$_SESSION['vOrder']." <= '%s' ", DB_TABLE_PREFIX, $order_item));
			$mSearch->dao->where('('.sprintf("%st_item.pk_i_id < %s ", DB_TABLE_PREFIX, osc_item_id()).' || '.sprintf("%st_item.".$_SESSION['vOrder']." < '%s' ", DB_TABLE_PREFIX, $order_item).' )');
			$mSearch->order(sprintf("%st_item.".$_SESSION['vOrder'], DB_TABLE_PREFIX), "DESC");
		} else{
			$mSearch->addItemConditions(sprintf("%st_item.".$_SESSION['vOrder']." >= '%s' ", DB_TABLE_PREFIX, $order_item));
			$mSearch->dao->where('('.sprintf("%st_item.pk_i_id > %s ", DB_TABLE_PREFIX, osc_item_id()).' || '.sprintf("%st_item.".$_SESSION['vOrder']." > '%s' ", DB_TABLE_PREFIX, $order_item).' )');
			$mSearch->order(sprintf("%st_item.".$_SESSION['vOrder'], DB_TABLE_PREFIX), "ASC");
		}
		$mSearch->limit('0', '1');
Any help on how to adapt to Tufftheme will be great.

At this point i can identify that in listing page in search we have, already category, region and city. But not the remaining values.

:mrgreen:
We made this function to be faster but above code is too slow to make entry in our theme.
No support for unnecessary PM, use forum for support queries.
Please give us good review if you bought our theme from Osclass Market
Locked