Hi,

I have an idea for a feature I would like to add to node auto term. I'm posting my idea here before I start coding so I can get some feedback about whether this is a good way of going about it.

What I am looking for is a way of managing bad NAT links. I.e. where someone is filling in a NAT linked field, but the node they are referring to does not yet exist. E.g. on the site I am building we will have the content types Listing and Event. Events have a venue which should refer to a Listing through the 'venue' field. I have built this as a NAT-linked taxonomy field, with NAT support added to the Listing type.

The problem comes if someone types in a venue for an Event that doesn't yet exist on the system. The taxonomy term is created, but it doesn't yet refer to a node, and at the moment NAT generates the broken path 'node/' for the link.

What I would like to add is a feature which marks the bad link and directs users to a page where they can correct it. I.e. for users with the permissions to add Listings, a badly linked venue field is shown in red when they view the page. If they click on the bad link they are taken to a configurable path where various options for correcting it could be displayed. The bad link path would be configurable in the 'manage display' section of the content type's edit form, using placeholders for variables like the term number, the full title of the term, the node with the bad link, and the name of the field affected. This way the person building the site would be able to choose their own way of handling bad links, (e.g. through a panel page with arguments and php code) rather than having to add a lot of functions to the NAT module to deal with this problem.

Could you let me know whether you think this is a feature that would be generally useful? If so I'll try to code it in a site independent way so it could be incorporated into the main release at a later date.

Thanks,

andy (ganglion)

CommentFileSizeAuthor
#5 nat.patch5.7 KBhighfellow

Comments

highfellow’s picture

I should add that I am using NAT with an autotagging field, which is maybe not how you envisaged it being used but is the way I want to set it up. What I'm thinking is that I don't mind there being a few bad links on the system, as long as they are clearly marked and easily correctable by either the author or another user with the right privileges.

highfellow’s picture

I have made a start on coding this feature. I'll post a patch here when it's done.

Zen’s picture

hi Andy,

I hope that I am understanding this correctly. But what you seem to be doing is the reverse of the default NAT behaviour - i.e., TAN. You want to automatically create a node when a term is created?

Regards,
Karthik.

highfellow’s picture

Roughly - what I want is for it to work in either direction - if someone creates a node then a term is created automatically by NAT, but if someone creates a new term in a free tagging field that doesn't correspond to an existing node, then I want the user to have the option of filling in the missing information in an intuitive way. The way I'm thinking of doing this is to have links to non-existent nodes flagged up in red (using class attributes), and redirected to a handler page. The link to the handler page would be an url with argument placeholders to denote things like the term number, full term title etc.

I wasn't thinking of coding the handler inside the NAT module, as different users might want to manage this in different ways, just to patch NAT so the links were redirected and then write my own page (probably as a panel with arguments and some custom PHP code) to handle bad links.

The handler page would say something like 'This venue has not been found on our system; you can help the site by filling in the missing information'. Below that there might be a view with some possible matches in case of bad or incomplete spellings of a venue name, and also a button which you could press to start creating a new node with the title from the term. The idea is to leave each step in the process up to the user - bad links are tolerated but not encouraged, somewhat like a wiki.

highfellow’s picture

Status: Active » Needs review
StatusFileSize
new5.7 KB

I have written some code to do what I was saying above, and created a patch against version 7.x-1.0-alpha4, which I have attached here.

This is just to redirect missing links to a handler page - I haven't yet written any code for the handler page itself. (I'm not planning to write this into NAT in any case; I'll probably write it first as some custom PHP code for a panel page, and then think about creating a separate module if appropriate.)

What this patch adds is:
- the NAT Link formatter for taxonomy term now has a setting called 'missing link handler path'.
- if someone adds a new term in an autocomplete taxonomy field which is linked with NAT, and the term does not correspond to an existing node, then...
- if the handler path has been set, the term is displayed as a link, using the CSS class 'nat-missing-link'. (I have chosen to display this in red on my site, but it could be any colour)
- the link points to the handler path set above (under edit content type | manage display), with the following tokens replaced if appropriate:
[node:*], [term:*], [nat-field-instance:id], [nat-field-instance:field-id], [nat-field-instance:field-name], [nat-field-instance:label] ('*' meaning any of the standard tokens for node or term)
- the idea of this is to use a path like 'nat-bad-link/[term:tid]/[nat-field-instance:id]/[node:nid]', where 'nat-bad-link' is the path to the page, and the tokens appear as arguments to that page.
- if the handler path has not been configured, then the term is displayed in plain text.

Hope you find this helpful,

andy

brooke_heaton’s picture

There are various issues with this patch. Can you elaborate on the functionality that this will provide and update this patch against the latest DEV version?