Keyword

Featured Ordering not work

More
8 years 7 months ago #147427 by MGS Creativa
Replied by MGS Creativa on topic Featured Ordering not work
Hi, sorry for my persistence, but I'm stuck in this web project because of featured items manual ordering misbehaving. If you need something on my part, just ask.

Thanks!

Please Log in or Create an account to join the conversation.

More
8 years 7 months ago #147454 by MGS Creativa
Replied by MGS Creativa on topic Featured Ordering not work
Hi, really sorry to bump this, but really need a fix, I can help if you want, just tell me what to try.

Thanks!

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #147458 by Krikor Boghossian
Replied by Krikor Boghossian on topic Featured Ordering not work
How did you encounter this error?
Is the ordering/ feature ordering being saved in the DB cells of the xx_k2_items table?
Also, did you check the network tab for the requests and their response?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
8 years 7 months ago - 8 years 7 months ago #147461 by MGS Creativa
Replied by MGS Creativa on topic Featured Ordering not work
Hi Krikor, thanks for your support!

I'll try to answer as clear as possible, but if you want to have access to my site backend, feel free to ask.

First of all, I have Joomla 3.4.4 and K2 2.6.9 mysql 5.5.44 PHP 5.5.9 Server Apache/2.4.7

Krikor wrote: How did you encounter this error?

This error arraises because I'm migrating a complete messy website into a new and more professional one, for that, I decided to migrate all contents (huge list by the way) from J! content to K2, so far so good. My site has a particularity, the homepage has to show only featured items and they have to be manually reordered in a regular basis over time. Doing so, I've found that featured items got reordered after manually ordering them.

Krikor wrote: Is the ordering/ feature ordering being saved in the DB cells of the xx_k2_items table?

I think that's not working, in this screenshot i.imgur.com/zKO1c9y.png you can see a query with a lot of items with "featured_ordering" set to 0!, this happened just after I set item id 845 to be the first by manual order, in the screenshot appears at 6th position with "featured_ordering" set to 0!

Krikor wrote: Also, did you check the network tab for the requests and their response?

This screenshot displays request result after set item id 17 first by manual reordering i.imgur.com/vd9iPgB.jpg and this one shows the featured item list after reloading the page after set item id 17 at first by manual reordering i.imgur.com/k5LGXTC.jpg

The request result has a lot of HTML because I have enabled XDebug, but the error is this:

Notice: Array to string conversion in libraries/joomla/filter/input.php on line 201
Call Stack
# Time Memory Function Location
1 0.0003 261904 {main}( ) .../index.php:0
2 0.0395 954184 JApplicationCms->execute( ) .../index.php:47
3 0.0395 954488 JApplicationAdministrator->doExecute( ) .../cms.php:252
4 0.0853 2190992 JApplicationAdministrator->dispatch( ) .../administrator.php:152
5 0.0860 2197368 JComponentHelper::renderComponent( ) .../administrator.php:98
6 0.0873 2209864 JComponentHelper::executeComponent( ) .../helper.php:372
7 0.0878 2228560 require_once( '/var/www/clients/client1/web2/web/residencias/administrator/components/com_k2/k2.php' ) .../helper.php:392
8 0.0954 2322608 K2HelperPermissions::checkPermissions( ) .../k2.php:39
9 0.0954 2322920 JRequest::getInt( ) .../permissions.j16.php:26
10 0.0954 2323064 JRequest::getVar( ) .../request.php:193
11 0.0954 2323320 JRequest::_cleanVar( ) .../request.php:152
12 0.0954 2323320 JFilterInput->clean( ) .../request.php:553



I think it's a K2 bug, because I'm expecting featured item list manual reordering to behave as Joomla! featured item list

If you need something else, just ask
Last edit: 8 years 7 months ago by MGS Creativa.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #147472 by Krikor Boghossian
Replied by Krikor Boghossian on topic Featured Ordering not work
This is what you should be seeing in the request imgur.com/nzP0jBY

If not, try to disable error reporting from your site's global configuration and try again.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
8 years 7 months ago - 8 years 7 months ago #147474 by MGS Creativa
Replied by MGS Creativa on topic Featured Ordering not work
Hi Krikor!, donde that, disabled error reporting on Joomla! config and got 1 as response, but the ordering misbehaiviour persists

Here is the result of set item id 845 at first, imgur.com/2XjKjmE then, after page reload, the order got missing! imgur.com/KC4Frq6

Really need to dig deeper, because I think it's some kind of issue with K2 or with new J! 3.4.4

Thanks!

PS: Really Krikor, do you want to have access to the site to check by yourself?
Last edit: 8 years 7 months ago by MGS Creativa.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #147477 by Krikor Boghossian
Replied by Krikor Boghossian on topic Featured Ordering not work
There is one more thing to check.

Can you try installing the dev version?
getk2.org/assets/get/

PS. Backup first

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
8 years 7 months ago #147478 by MGS Creativa
Replied by MGS Creativa on topic Featured Ordering not work
Sorry Krikor, no luck.

After installing dev build, tried to set items ID 17 and 777 respectively imgur.com/x8lT6Wh, but after reload reorder still gets missing imgur.com/b7HOIHs

Please Log in or Create an account to join the conversation.

More
8 years 7 months ago - 8 years 7 months ago #147481 by MGS Creativa
Replied by MGS Creativa on topic Featured Ordering not work
Hi, after debugging the savefeaturedorder() member function of the items model I can see that in line 362 the featured_ordering is compared with standard ordering and that creates the messy ordering!

As far as I can tell, the cid post var contains the manual reordeing array of IDs ans looks just fine, but the order post var has another array of IDs and the order looks juast as what you get after reloading the page. I think that for featured items, that var should not be taken into account.
function savefeaturedorder()
	{
		$mainframe = JFactory::getApplication();
		$db = JFactory::getDBO();
		$cid = JRequest::getVar('cid', array(0), 'post', 'array');
		$total = count($cid);
		$order = JRequest::getVar('order', array(0), 'post', 'array');
		JArrayHelper::toInteger($order, array(0));
		$groupings = array();
		for ($i = 0; $i < $total; $i++)
		{
			$row = JTable::getInstance('K2Item', 'Table');
			$row->load((int)$cid[$i]);
			$groupings[] = $row->catid;
			if ($row->featured_ordering != $order[$i])
			{
				$row->featured_ordering = $order[$i];
				if (!$row->store())
				{
					JError::raiseError(500, $db->getErrorMsg());
				}
			}
		}
		$params = JComponentHelper::getParams('com_k2');
		if (!$params->get('disableCompactOrdering'))
		{
			$groupings = array_unique($groupings);
			foreach ($groupings as $group)
			{
				$row = JTable::getInstance('K2Item', 'Table');
				$row->reorder('featured = 1 AND trash=0', 'featured_ordering');
			}
		}
		$cache = JFactory::getCache('com_k2');
		$cache->clean();
		return true;
	}
Last edit: 8 years 7 months ago by MGS Creativa.

Please Log in or Create an account to join the conversation.

More
8 years 7 months ago #147484 by MGS Creativa
Replied by MGS Creativa on topic Featured Ordering not work
Well, I think I found a workaround!, but beware, I think it may break other ordering scenarios, tested reordering with selected cat with subcats and works fine, and tested wit cat with subcats ans featured filter and gets messy as before (because hits if ($row->featured_ordering != $order[$i])). If I select no filter but featured, then reordering works just fine!, in file administrator/components/com_k2/models/items.php, changed member function savefeaturedorder() to this:

Basically takes into account if the list given is only featured items and then reorder the items by cid post param if not, then do actual k2 stuff (that may be buggy)
	function savefeaturedorder()
	{
		$mainframe = JFactory::getApplication();
		$db = JFactory::getDBO();
		$cid = JRequest::getVar('cid', array(0), 'post', 'array');
		$total = count($cid);
		$order = JRequest::getVar('order', array(0), 'post', 'array');
		$filterauthor = JRequest::getVar('filter_author', 0, 'post', 'integer');
		$filtercategory = JRequest::getVar('filter_category', 0, 'post', 'integer');
		$filterfeatured = JRequest::getVar('filter_featured', 0, 'post', 'integer');
		$filterstate = JRequest::getVar('filter_state', -1, 'post', 'integer');
		$filtertrash = JRequest::getVar('filter_trash', 0, 'post', 'integer');
		JArrayHelper::toInteger($order, array(0));
		$groupings = array();
		for ($i = 0; $i < $total; $i++)
		{
			$row = JTable::getInstance('K2Item', 'Table');
			$row->load((int)$cid[$i]);
			$groupings[] = $row->catid;
            if ($filterfeatured == 1 && $filterauthor == 0 && $filtercategory == 0 && $filterstate == -1 && $filtertrash == 0)
			{
			    $row->featured_ordering = $i;
			}
			else if ($row->featured_ordering != $order[$i])
			{
				$row->featured_ordering = $order[$i];
			}
			
			if (!$row->store())
			{
			    JError::raiseError(500, $db->getErrorMsg());
			}
		}
		$params = JComponentHelper::getParams('com_k2');
		if (!$params->get('disableCompactOrdering'))
		{
			$groupings = array_unique($groupings);
			foreach ($groupings as $group)
			{
				$row = JTable::getInstance('K2Item', 'Table');
				$row->reorder('featured = 1 AND trash=0', 'featured_ordering');
			}
		}
		$cache = JFactory::getCache('com_k2');
		$cache->clean();
		return true;
	}

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum