Provide a full featured views integration.

In general it should be written in a way that the user can see that this doesn't come from taxonomy_index buy from taxonomy_enitity_index.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review
FileSize
13.42 KB
bforchhammer’s picture

Status: Needs review » Needs work

I have tags on file entities and wanted an exposed taxonomy filter for a list of files (See #1371974: Exposed taxonomy filter on file view only shows up as numeric input field). This module + patch above allows me to do that.

I created a relationship for the "taxonomy terms on file", then added a respective exposed filter ("Taxonomy Term: Term")... and that filter works just as expected.

Is there something in particular that needs testing on the patch, or anything else that I can help with on this issue?

bforchhammer’s picture

Minor spelling mistake:

+++ b/taxonomy_entity_index.module
@@ -203,3 +203,49 @@ function taxonomy_entity_index_reindex_entity_type($entity_type, &$context) {
+function taxonomy_entity_index_entity_views_integretable($data, $entity_type = NULL) {

"integretable" should probably be "integrable", see: http://dictionary.reference.com/browse/integrable

I also get this notice on the views page:

Notice: Undefined index: base table in taxonomy_entity_index_entity_views_integretable() (line 275 of [...]\sites\all\modules\taxonomy_entity_index\taxonomy_entity_index.module).

bforchhammer’s picture

Status: Needs work » Needs review

Sorry, just realised that I inadvertently changed the status.

james.williams’s picture

I have a view that uses a taxonomy with depth filter handler based on the with depth argument provided in the patch, but because I have 30,000+ rows in my taxonomy entity index, the SQL query takes several minutes (!) to execute. Your handler (and mine) is based on the standard views taxonomy handlers, but these are massively quicker, because they have an additional database index, on the 'nid' field (see taxonomy_schema()). Should taxonomy_entity_index not need one too? This also raises the additional issue of whether the current handler needs some extra work on its subquery, since surely it shouldn't only be selecting by entity_id, but by entity_type & revision_id instead?

james.williams’s picture

The attached patch solves the problems I raise above - namely, an index is needed on the DB table, and the views 'with depth' handler needs to filter by revision_id & entity_type rather than entity_id. I have also added my 'with depth' views filter.

james.williams’s picture

Forgot to say this in my previous comment, but I've also addressed the issues raised by bforchhammer in my latest patch.

And just in case anyone is interested, I have a sandbox which I am using as a fork of taxonomy_entity_index module that has this patch applied to it, plus the patch for an admin form to batch process existing entities (http://drupal.org/node/1207794#comment-5165764). This is at http://drupal.org/sandbox/jameswilliams/1424466

klaasvw’s picture

This patch adds the following things:

  • Combines the patches from #1 and #6.
  • Adds a taxonomy term width depth filter
  • Fixes the missing taxonomy term id argument and has taxonomy term filter by joining with every entity table.
  • Makes sure all new fields, filters and arguments are assigned to the appropiate Taxonomy Entity Index group
  • Makes sure handlers for entities have the entity type mentioned in their title.

Would be great if we could get this to RTBC. This module would be so much more useful with views integration.

bforchhammer’s picture

klassvw: I tried your patch, but it seems to be missing a few changes, e.g. the .module file still has taxonomy_entity_index_entity_views_integretable whereas other functions reference taxonomy_entity_index_entity_views_integrable... Could you check again, please? Also, did you actually change anything or is it the same code as in james' sandbox?

I agree that it would be great to get this moved along... so we can maybe get rid of the various different sandboxes that people use at the moment ;-)

bforchhammer’s picture

I have been using patch #1 for a while without problems, and I have now switched to james' sandbox. I have not stumbled on any major problems.

Only issue that was a little confusing during testing: the Views UI currently shows three taxonomy term filters:

  1. Taxonomy term: Term: the one I have been using, works well for me.
  2. Taxonomy Entity Index: Has taxonomy term: does not work at all; respective code file suggests that it was only a placeholder... (?)
  3. Taxonomy term: Has taxonomy terms (with depth and indexed in taxonomy_entity_index): the new one added by james, not tested yet.

Should 2. be removed, as 1. already seem to do what that one was supposed to?

klaasvw’s picture

This patch fixes the taxonomy_entity_index_entity_views_integretable I missed. It also fixes these issues:

  • Join each entity table on entity_id instead of tid
  • Added entity_type where condition to the taxonomy_entity_index_handler_argument_tid_depth and taxonomy_entity_index_handler_filter_taxonomy_entity_index_tid_depth.inc handlers

@bforchhammer Yeah, we should look deeper into which handlers can be eliminated and if there are any missing. I'll look into it deeper in the next version of the patch.

bigjim’s picture

I rerolled the patch from #11 with a few edits/fixes.

- added the call to hook_views_api()
- Added the files to the .info file
- cleaned up handler names to be more consistent ie change taxonomy_entity_index_handler_field_taxonomy_entity_index_tid to taxonomy_entity_index_handler_field_tid etc...
- removed the 2 empty handlers, presumably they can get added back when they do something? Views was throwing "failed to load" errors.
- added taxonomy_entity_index_entity_views_integrable() back into module file.

vood002’s picture

I've applied the patch in #12, but don't have any new options in my view.

I have a content view that users can use to manage content. It filters by Taxonomy, and the reason I'm attempting to use this module is because unpublished entities disappear when filtering by taxonomy.

It's my understanding that this module can provide a workaround...however after installation I have no new options under "Contextual Filters". Am I missing something?

bigjim’s picture

@vood002 you've cleared all the caches (including Views caches, which must be done form the Views UI), etc... ?

vood002’s picture

@bigjim: Thank you very much for the reply...I wasn't able to determine from the thread if this patch should be working for me but your response convinced me. The issue ended up being in my having used the incorrect patch command that didn't respect the directory structure of the module. Having cleaned this up and reindexed all my nodes this module+patch is working perfectly for my purposes. Thank you!

bigjim’s picture

Status: Needs review » Reviewed & tested by the community

@vood002 no worries

moving to RTBC

kaizerking’s picture

Views filter handler broken error
I am getting this error after this patch

kaizerking’s picture

FileSize
60.27 KB

I have proifle2, field collect field is attached to profile2, multi value term reference field is attached to field collection field please see attached mySql table screen shot
I have a content type where the same term reference field is used while creating content,
Now, I want to create a view, of content filtered by term reference fields of profile, The entity index table is created, a really nice structure exactly what i wanted, But how to create a view creating this entity index table?
can some one help me.

bigjim’s picture

@kaizerking I'm not 100% sure I follow you but you should see Contextual Filters, Filters, and field under the group "Taxonomy Entity Index". Is that there?

kaizerking’s picture

FileSize
28.22 KB

I can find Taxonomy entity index under , contextual filters,Filters, relations
But under format ->fields when i select Taxonomy entity index i get this "The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item."
plz see attached screen shot

how ever I am getting the table alright, if some one can help me in creating the view as requested @#18 That would be a great help

dawehner’s picture

@kaizerking
Are you sure you cleared the cache and rebuilt the registry?

kaizerking’s picture

yes, I have installed and uninstalled many times, cleared cache too each time
to help you understand here is my structure:
the structure is as follows for better understanding i am giving the level numbers
Level 1:Profile2
------------Level 2 :Field collection item 1(multi-value)
-----------------Level 3:Term reference field(multi-value)
---------------------------value1
---------------------------value2
------------Level2 :term reference field(this is directly attached to profile2this is also multi-value
---------------------------value1
---------------------------value2
What I am trying to do is get all the nodes filtered by all the terms(reduced duplicates) , When i am selecting TEI in fields this is the message i am getting:
"Broken/missing handler (Broken handler node.taxonomy_entity_index_entity_tid)" , I think it has something to do with multi-value

bigjim’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
14.87 KB

@kaizerking I have the field message tracked down line 54 of the taxonomy_entity_views.views.inc file was looking for a handler named "taxonomy_entity_index_handler_field_index_tid" it's in fact name "taxonomy_entity_index_handler_field_tid" (ie take out the 2nd "index"). Sorry I missed that I was mostly focused on the contextual filters in my testing.

I'm not sure this explains your other issues with filters from #17 but can you test this patch? If you still get errors does it work without the multi-value field or field collections?

- moving back to needs review

kaizerking’s picture

i'll check and revert

kaizerking’s picture

FileSize
10.36 KB

Now the TEI is available in fields, but
I am getting this error:
Notice: Undefined index: entity_id in taxonomy_entity_index_handler_field_tid->pre_render() (line 32 of C:\xampp\htdocs\....\sites\all\modules\taxonomy_entity_index\includes\views\handlers\taxonomy_entity_index_handler_field_tid.inc).

Please have a look at attached my_view

kaizerking’s picture

@bigJim, I do not want this issue to be pending just because of my this issue , My use case is very typical, And bit confusing.I am posting admin login details through contact form to you for your convenience if you do not mind please have a look. this will make things faster and get this committed.

kaizerking’s picture

It seems , if an entity is attached to another entity, it,s parent entity should also be indexed as hostEntityId, hostEntity(bundle), hostEntityType in addition to its own Entity ID,Enity(Bundle),Entity_type data to get the field relation to parent entity

perfect example is my use case, a term reference field is attached to field_collection_item and the field collection item is attached to Profile2, when we see the TEI table now, this information is missing, the table lists the entity ID of the field collection but not the hostEntityId to which this is attached , this will cause a missing data when we are trying to create join term reference field and the profile2 relation ,since the filed is not directly related to profile2.Since entity system is being adopted for all future developments this will be advantageous.

Please consider this, as this will reduce lot of custom joins

kaizerking’s picture

After applying this patch Profile2 patch I don't get this error at #25 any more

bigjim’s picture

@kaizerking have to admit I'm a little confused. In your opinion is it safe to say this patch is ready to go?

kaizerking’s picture

That patch is not committed yet,Yes it is safe to go after that patch is committed, But there is no point,I have questions on the usage of this module
Taxonomy entity index deals with custom entity types. what about the 'entities' attached to 'entities'?
the relation is not captured properly
I have field collection fields attached to profile2 entity,
When i see the Taxonomy entity index table. I get multiple entries , if you see screen shot attached aboveTaxonomy index table view
in that table you can see field collection items, in fact all those field collection items are attached to profile2 which you can see at the bottom. When i want to create a contextual filter- field collection fields are not recognized as part of/attached to- profile2.and i need to do a separate join with relations,apart from Taxonomy entity index
this will be the dis advantage of this module
A entity wich has hostEntityId , hostEntity, hostEntityType details as Entity meta data which
can also be found in get_entity_info, and entity_extract_ids array, I request if you could accommodate that info
in my case the hostEntity will be my resume and so on , unless this data is pulled to taxonomy entity index this table/module is useless
kindly please support this issue, this will be great module to deal with entities which have terms

bigjim’s picture

Status: Needs review » Reviewed & tested by the community

@kaizerking I'm with ya on the issue but that really should be another ticket as it's an edge case and has a work around.

marking RTBC

sokrplare’s picture

Patch attached to comment #26 is working beautifully for me as well for an exposed filter on image file entities.

Heorhi Lazarevich’s picture

Fork of taxonomy_entity_index module mantioned in #7 is working beautifully for me on nodes entities with additional views 'with depth' filter handler together with taxonomy_display and view_unpublished modules

saltednut’s picture

Version: 7.x-1.0-beta4 » 7.x-1.x-dev
Status: Reviewed & tested by the community » Needs review
FileSize
14.87 KB

Re-rolled this for latest dev. Would like to get a few more eyes on this before committing and making a new release.

dawehner’s picture

Great to see some progress here, damn this issue is really old.

+++ b/taxonomy_entity_index.moduleundefined
@@ -236,3 +236,50 @@ function taxonomy_entity_index_reindex_finished($success, $results, $operations)
+function taxonomy_entity_index_entity_views_integrable($data, $entity_type = NULL) {

I'm wondering why this should be put into the module file, as it's just used in the .views.inc file?

saltednut’s picture

@dawehner I was wondering about that too when I rerolled but I thought maybe someone had a good reason.

dawehner’s picture

It was part of my initial patch in #1, so it feels okay to move in. In general it's better to have at least something that works for many
people then nothing.

+++ b/includes/views/handlers/taxonomy_entity_index_handler_field_tid.incundefined
@@ -0,0 +1,74 @@
+      $query = db_select('taxonomy_term_data', 'td');
+      $query->innerJoin('taxonomy_entity_index', 'tei', 'td.tid = tei.tid');
+      $query->innerJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+      $query->fields('td');
+      $query->addField('tei', 'entity_id', 'entity_id');
+      $query->addField('tei', 'entity_type', 'entity_type');
+      $query->addField('tei', 'revision_id', 'revision_id');
+      $query->addField('tv', 'name', 'vocabulary');
+      $query->addField('tv', 'machine_name', 'vocabulary_machine_name');
+      $query->orderby('td.weight');
+      $query->orderby('td.name');
+      $query->condition('tei.entity_id', $entity_ids);
+      $query->condition('tei.entity_type', $this->base_table_info['table']['entity type']);
+      $query->addTag('term_access');
+      $vocabs = array_filter($this->options['vocabularies']);
+      if (!empty($this->options['limit']) && !empty($vocabs)) {
+        $query->condition('tv.machine_name', $vocabs);

I know all this code is pretty much a copy + adaption of the parts which exists in views for the taxonom_index table, but in general stuff like that could be cleaned up quite a bit to use efq instead. Sounds like a good followup.

+++ b/includes/views/handlers/taxonomy_entity_index_handler_filter_tid_depth.incundefined
@@ -0,0 +1,78 @@
+      $operator = 'IN';# " IN (" . implode(', ', array_fill(0, sizeof($this->value), '%d')) . ")";

Another bit, which for sure could be cleaned up in a followup.

saltednut’s picture

Status: Needs review » Fixed

Agreed - we can leave it to followups for the optimization bits. http://drupalcode.org/project/taxonomy_entity_index.git/commit/bc548a1

Status: Fixed » Closed (fixed)

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