Problem/Motivation

When viewing the My Content tab, users can click the table heading to sort by Title, Type, Published, Author or Last Updated. However, if they select Section the sorting fails to return results.

NOTE: I don't know if this impacts the issue, but in our installation our Editorial Sections are comprised of multiple Taxonomy Vocabularies.

Comments

dave reid’s picture

Version: 7.x-1.0-beta6 » 7.x-1.x-dev
Status: Active » Postponed (maintainer needs more info)

I cannot duplicate this using the latest code will try with a more complex section setup.

stevector’s picture

Project: Workbench » Workbench Access

Changing the project for this issue. The "section" column comes from Workbench Access.

agentrickard’s picture

StatusFileSize
new26.08 KB

I'm not seeing that, but I am getting duplicate results when sorting and using the 'menu' scheme.

The duplicates only appear after sorting by section. These bugs are probably related.

agentrickard’s picture

Status: Postponed (maintainer needs more info) » Active
agentrickard’s picture

I can replicate something similar to the original issue as well. We may just need to remove the sorting feature.

agentrickard’s picture

For taxonomy, line 33 is not returning any value, which may be breaking the query.

      $table = $this->query->ensure_table($sort['table']);

I've always struggled with that method, which seems very inconsistent in Views.

The table _is_ correctly added when using menus, but I believe the JOINs are causing duplicate records.

dave reid’s picture

We should probably just remove the sort-ability considering that multiple sections can be in the field.

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new837 bytes
dave reid’s picture

Status: Needs review » Needs work

Tested #8 manually and ran tests. Committed to Git.
http://drupalcode.org/project/workbench_access.git/commit/d0c2efb

Moving back to needs work for investigation.

robeano’s picture

Status: Needs work » Fixed

We are not supporting a sort by Section column at this time. The commit from #1243186-9: Workbench: My Content Tab: Sort by Section Fails removes this capability. We're all set here.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ann b’s picture

This is just for documentation. I have a view that needs to be sorted by section. In my case only one section can be assigned to a node, so it worked for me:

function mymodule_views_query_alter(&$view, &$query) {

	if (is_numeric(strripos($view->tag, 'WB_CLONE')) && ($view->base_table == 'node' || $view->base_table == 'node_revision')) {

		$join = new views_join();
		$join->type = 'LEFT';
		$join->left_table = 'node';
		$join->left_field = 'nid';
		$join->table = 'workbench_access_node';
		$join->field = 'nid';

		// Do the actual join
		$query->table_queue['workbench_access_node'] = array (
		  'alias' => 'workbench_access_node',
		  'table' => 'workbench_access_node',
		  'relationship' => 'node',
		  'join' => $join,
		);

		$join = new views_join();
		$join->type = 'LEFT';
		$join->left_table = 'workbench_access_node';
		$join->left_field = 'access_id';
		$join->table = 'taxonomy_term_data';
		$join->field = 'tid';

		// Do the actual join
		$query->table_queue['taxonomy_term_data'] = array (
		  'alias' => 'taxonomy_term_data',
		  'table' => 'taxonomy_term_data',
		  'relationship' => 'workbench_access_node',
		  'join' => $join,
		);

		$query->fields['my_section'] = array(
		      'field' => 'name',
		      'table' => 'taxonomy_term_data',
		      'alias' => 'my_section'
		);

		$section_sort = array(
		      'field' => 'my_section',
		      'direction' => 'ASC'
		);

		array_unshift($query->orderby, $section_sort);

	}

}

Thanks to this post for the instructions on how to modify a views query. The database api methods don't work here.