Joining two terms together in a single Item

patchak - November 5, 2006 - 14:02
Project:MySite
Version:HEAD
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hi,

I have a news site and a really like mysite module so that users can follow specific keywords that they would like to follow. A couple of users asked me if it would be possible to create more advanced queries so they could for example follow "term1 + term2" meaning that those nodes must have both terms to be pulled out of their item listing.

The use case on my site is because I have "locations" and "terms" so a user would like to have nodes from "term" but at a single "location". that would permit him to build himself a nice local newspaper.

Any comments about this?
Is it a good idea?

Thanks

#1

agentrickard - November 6, 2006 - 14:27

That's a good idea, but tricky to implement the way the module is currently coded.

I explicitly chose not to use parent-child relationships in the term.inc file. This isn't the same issue, but it is similar. The problem arises in that the type_id field in the mysite_data table is a single integer. Here, you want to store a string. Not allowed under the current design.

I'm reluctant to change the type_id field to a string, because I think that over-complicates the module code. 95% of Drupal keys are single integers.

This functionality could be handled in a separate type plugin (call it 'myterms' for instance). Two problems to overcome:

1) What is the UI for selecting multiple terms? Two select menus are typical and would be easiest to code.

2) How to store the values (the type_id key that MySite's mysite_data table needs). If the terms had a relationship defined in the term_hierarchy or term_relation tables, then this would be fairly easy to do. If you need to link terms from two separate vocabularies, I think you might need an additional table to store those relations. Here's how:

table mysite_terms

field: mtid = #
field: tid1 = a term id
field: tid2 = a term id

But in this approach, you inevitably hit the 'what is the limit to the number of terms a user can associate?" problem. So you could store the 1+2+4+10 string and explode it during the query.

The key here is solving issue #1. Then issue #2 is easier.

If, for instance, you want admin-defined term relationships, that could be done either through term_relations or through a settings tab for the myterms.inc file.

If you want the user to define the relationship, then it gets more complex.

The fastest solution is to create a type plugin that meets your needs and stores the data into a new table, I think.

#2

patchak - November 6, 2006 - 14:38

Hi,

Well, I though personnaly to let users add 2 or 3 terms together, as they choose. In fact at the moment I'm lookng at the aggregator type to let users get the feed from taxonomx pages of their choice (with joined terms if they want)

Would it be possible to simply add a button 'add to mysite' at the side of each syndication icon??' That way a user could

1) build a view of it's choice
2) add it to his mysit as a feed
3)follow the terms he wants simply without really coding a new type.

the only thing is that now he would have to copy the adress of the feed to paste it, is it possible to integrate an automated link of some kind??

thanks

#3

agentrickard - November 6, 2006 - 14:53

> Would it be possible to simply add a button 'add to mysite' at the side of each syndication icon??'

Not directly, I don't think. But you could use MySite's block handler to add it to the MySite block. Are you referring to the RSS icon created normally by Drupal. or the one added by the syndicate module?

As for using Aggregator, I think that would work (it's a smart idea that never occurred to me.) In terms of MySite, this would be handled by the feed.inc file (since we're adding an individual feed to the user's collection).

We'd probably need a callback function to handle the addition of 'self-referential' aggregator feeds (feeds that come from your Drupal site). The link would be something like this:

  1. Add (term names string) to your MySite page
  2. Links to: mysite/add/feed/terms/1+2+3+4
  3. Goes to: function mysite_type_feed_add(), which would handle the request, create the appropriate feed, and add it to the user's MySite.

#4

patchak - November 7, 2006 - 08:06

Hey there,

Are you interested in implementing this, cause i'm really not a coder, so I could not do it at all... If you are not interested in coding this, could you help me do it??

Thanks

#5

agentrickard - November 7, 2006 - 14:27

Actually, after a night's sleep, I realized that this approach won't do want your users are asking for.

Going to example.com/taxonomy/term/1+2+4 will return:

All nodes in either term 1 or term 2 or term 4.

What you want is:

Any nodes tagged with term 1 and term 2 and term 4.

So there would have to be a mechanism for making collections across terms.

I don't know of any modules that do that, but you might check through the taxonomy modules and see if one will. Then we could write a plug-in for that module.

Otherwise, we'd have to write a custom plug-in (or a module and plug-in) to handle the creation of these relationships.

#6

patchak - November 7, 2006 - 15:06

Sorry I did not mention this on my last post... but you can do exactly that with the refine_by_taxo module which I installedon my site.

So users are actually able to compose AND lists for terms, simply by using the links in the blocks on the right side.

Have a look here :

www.notreactualite.com // click on a term to see the related links...

hummm... Then I guess the first part of the problem is solved, and I know that the rss feed that is outputted by those pages can be used (not like views who does not give an rss feed for user-filtered views.

So that's it, have a look at it, I implemented mysite on my site so feel free to open an account on my site and fool around.

I got a a couple more feature requests going your way, so we'll keep in touch lol

keep me posted on this thing.

patchak

#7

agentrickard - November 7, 2006 - 16:58

My French is decent. but spotty.

What is the French title for the refine_by_taxo block?

#8

agentrickard - November 7, 2006 - 17:05

I found it.

It looks like a plug-in for refine-by-taxo would do the trick.

#9

agentrickard - November 7, 2006 - 18:34

This is really a development note.

A similar issue came up in another thread, and leads to the following feature for 5.x:

Create a table that allows pluigns to store the following:

mysite_plugins

  • MYID == the unique id for this entry (primary key)
  • TYPE == the plugin type (indexed)
  • MYKEY == the unique data key for this item (optional)
  • CONTENT == the content to display for this item (optional)

MYKEY would be a serialized string or array, containing the content that the plugin needs to run the proper query. (In this case, $terms = array(1,2,4), which would be translated by the taxo.inc file to run the mysite_type_taxo_data() query.)

CONTENT would be used in the case that an admin wants to set up a content block like the local weather, or other Google-style content blocks. These may or may not need MYKEY fields as well.

In the mysite_data table, we can then store the MYID and TYPE normally.

#10

patchak - November 8, 2006 - 15:19

Hi!
Glad you liked my idea about how to implement the multiple terms feed... Like I said I'm not a programmer and I can barely touch a php file... so I guess that leaves me the option to ask you if you are interested in pluggin this into your module. I would be open to "sponsor' certain features eventually so maybe you could drop me a line about this specific feature and what amount of time would be needed to make something cool and well integrated out of it??

cya and thanks again
patchak

#11

agentrickard - November 8, 2006 - 16:18

Well, the concept to support your idea is going into the v5 code anyway. As for a custom type file, we can talk later.

If you need this _right now_ in 4.7, send me a note using the contact form.

#12

agentrickard - November 9, 2006 - 20:02
Status:active» postponed

#13

agentrickard - November 12, 2006 - 17:08
Version:4.7.x-1.x-dev» HEAD
Component:User interface» Code
Status:postponed» active

The mysite_plugins table likely also needs a TITLE field, allowing admins to define a title for the content element.

#14

agentrickard - November 21, 2006 - 20:27

I've taken a first stab at this, and it seems to work. Here's the current logic.

- refine-by-taxo defines a MySite block.
- when that block loads, a mysite entry is created in the new mysite_content table.
- refine-by-taxo items can be added/removed from MySite normally.

I will do some cleanup and then try to add a new release.

#15

patchak - November 21, 2006 - 20:58

Hi,

So you mean I could actually filter by two, three terms and then add that resulting filtered view to the mysite?

Would it be possible to give it a custom name? How is the interface working with the mysite??
Thanks for your work on this.

cya

#16

agentrickard - November 22, 2006 - 14:17

The way it works now is that any time you're on a taxonomy page that looks like this:

example.com/taxonomy/term/1,2,3,4

I create an entry into the MySite content table that maps 'terms 1,2,3,4' == "names, of, terms". This content is then available to add to a user MySite. Caveat: the MySite block must be turned on.

In the new release, there is also a settings hook for all type files, so the refine.inc could have settings that let you define the names of specific category clusters.

We'll probably need to put in an admin page that lets you define and edit the category clusters.

#17

patchak - November 22, 2006 - 16:33

sounds really good!

Can't wait to see that in action and to implement it on my site!

thanks,
Alex

#18

agentrickard - November 26, 2006 - 23:29
Status:active» closed

Implemented in the 4.7-3 branch.

 
 

Drupal is a registered trademark of Dries Buytaert.