I created two content types:
Step1:create a content type "player" and add cck fields player_number and player_name, the node-title is build by modules autonodetitle and token, so it's the same as player_name, create some players
Step2: create a content type "tournament" and add one or more node reference field/s to content type player,
The select list is sorted alphabetically by node-title of content type "player", so by player_name
I'd like to sort the list by player_number, so I created a new view (views2-module) with fields player_number and player_name and sort-criteria player_number ASC. I referenced the nodereference-field "participant" to this view.
Now, the select list shows the following sorted fields: player_number, player_name and "title":title (the player_name)
So the player_name is doubled.
How can I hide the title of the referenced node in the select list ?
I think, it's not a big problem, because only the node_nid is stored in database.
Comment | File | Size | Author |
---|---|---|---|
#5 | sreenshot.jpg | 81.95 KB | Micha1111 |
Comments
Comment #1
likewhoa CreditAttribution: likewhoa commentedjust ran into this and would like an answer as well, It seems the node reference's view feature is the issue here but one needs to select a view and only show what that view is querying not the extra "title foobar" bit.
Comment #2
likewhoa CreditAttribution: likewhoa commentedComment #3
likewhoa CreditAttribution: likewhoa commentedComment #4
drewish CreditAttribution: drewish commentedyou just need to setup the view correctly. if you're seeing "title" you need to remove the label from the field name. if you're seeing double values you need to remove the duplicate fields.
Comment #5
Micha1111 CreditAttribution: Micha1111 commentedI think, this solution is not a fix, because the view has only two fields (player_number and player_name with labels) without node-title of nodes from nodetype players (sreenshot2)
But the node-title is shown in cck-form-selectfield. (sreenshot1)
After deletion of the label of field player_number and delition of the field player_name (sreenshot3), the player_number and the node_title (with label "Titel:" are shown in cck-form-selectfield (sreenshot4).
So the node-title is always shown, but it isn't set in views-settings !!
Comment #6
drewish CreditAttribution: drewish commentedah, you're right. talked to yched on irc and the solution is to exposed a views display and let you create your own fields.
Comment #7
yched CreditAttribution: yched commentedActually, this is not related to whether the custom view display we use is exposed or not. The fact is that we explicitly force the node title (or user name, in the case of userrefernce fields) to be present as a field in the view.
_nodereference_potential_references_views() :
This is because the 'autocomplete' widget needs the node title to fill in "node_title [nid:node_id]" in the textfield when the user picks an autocomplete suggestion. Granted, the other widgets (select, radios/checkboxes) don't need it, but the code workflow is pretty tight and it's hard to do special cases. I don't really see a workaround here.
Comment #8
drewish CreditAttribution: drewish commentedyched, well that pretty much defeats most of the value of using views for the lists... are you sure we couldn't come up with some kind of a work around?
Comment #9
yched CreditAttribution: yched commentedThat sounds a little dramatic - it's been like that since 4.7, and I think the feature found a few use cases since then, even with that limitation ;-)
Well, thinking about it a little more, there should be a way to have a db field (node title) retrieved in the views results but not being part of the actual views 'fields' . If this can be done (and if we have a consistent way to get it from the results, whether 'node: title' field is actually present in the view or not), then we could alleviate that constraint.
Then, of course, comes the usual issue of changing the behavior of existing setups : after upgrading to cck 2.2, the titles disappear from my noderef widgets if my view didn't have the title field so far.
Comment #10
KarenS CreditAttribution: KarenS commentedThe Views UI has a checkbox for field options that are needed in the query but not to be displayed. Maybe there is some way to use that to include the field but not display it. I haven't looked into the Views code to see where that comes in to play or exactly what it would change in these results.
Comment #11
yched CreditAttribution: yched commentedTrue, I forgot that option. This might be a solution - if the 'title' field is not present, we force it in as 'not displayed'.
Patch anyone ? :-)
Comment #12
drewish CreditAttribution: drewish commentedyched, i think the option you're thinking of is "exclude from display"... but if the ajax needs the title to match nids then that seems like the bigger stumbling block...
Comment #13
Micha1111 CreditAttribution: Micha1111 commentedPerhaps, it's easier to hide only the label of the node-title ?
I mean: "Title:"
That's ok for me, because I build the node-title with modules token and autonodetitle from field player_name, so node-title and field player_name are always identical.
Comment #14
kenorb CreditAttribution: kenorb commentedMarked #350174: get rid of Title from autocomplete referenced field when using Views as duplicated.
Title is added in _nodereference_potential_references_views():
I've commented out this line:
Then it's throwing the error:
That's:
So I've changed this code to:
And it's seems to work fine.
I don't care for now that there is no title in the field (#7). It should be replaced with some field as well.
I think without Title in autocomplete list is looks better than without Title in the field.
In some cases some people don't use title at all, because auto_nodetitle doesn't generate titles from the fields during creation, so for most of the cases Title contain rubbish.
Probably most of the people who wanted to hide the Title now will be interested with searching string in CCK fields as well via autocomplete:
Here is related case: #375690: Nodereference autocomplete doesn't match all of view's fields
Comment #15
CobraMP CreditAttribution: CobraMP commentedthank you kenorb. so I'm curious if the dev version, or next drop of cck will include something to be able to drop the title via the UI?
Comment #16
jlevy CreditAttribution: jlevy commentedI've been able to work around this issue:
1) add the title field to your view
2) check the 'exclude from display' box for that field
That should do it until the bug is fixed.
Jeff
Comment #17
likewhoa CreditAttribution: likewhoa commentedI don't see this being an issue with latest -dev for me anymore.
Comment #18
kenorb CreditAttribution: kenorb commentedI'm not sure if you talking on the same thing, but I don't see much changes and title is still hardcoded.
Comment #19
kenorb CreditAttribution: kenorb commentedBut I think #16 is a good solution.
I've tested and it's working.
The only issue is to replace the title of field somehow after selected some record.
If somebody will have better solution, please re-open it.
Comment #20
yched CreditAttribution: yched commentedChanging the code to force-add the 'title' field as 'excluded' if it is not present in the original view seems an easy change.
My main worry is that it will break existing sites that might implicitly rely on the fact that the title was added no matter what.
Comment #21
kenorb CreditAttribution: kenorb commentedyched: it can be solve in similar way to this one:
http://drupal.org/node/375690#comment-1263293
Most of the views used as argument have no fields defined because are not supported, so if there are some fields defined, we can replace them instead of default title. I think it will not break existing websites.
Comment #22
yched CreditAttribution: yched commentedI fail to see how this is a fix.
Sample break case :
I created a view with filters and sorts to define the nodes that are refererencable in my field_noderef field. I didn't even have to bother about adding actual fields to the view, it works out of the box (displaying titles). Then I install the new version of CCK that behaves as decribed in #20. Nothing displays in my select box or in the autocompletion results anymore => I have to manually edit the view and add the title.
I don't think there's a workaround.
Comment #24
javi-er CreditAttribution: javi-er commented#16 worked perfect for me.
Comment #25
likewhoa CreditAttribution: likewhoa commented#16 is not a workaround re-opening since cck fields are still being appended with '- Title: Name' after content.
Comment #26
timtrinidad CreditAttribution: timtrinidad commentedI know this issue is pretty old, but I used the following workaround: include the "Node: Title" in the fields, remove the label (i.e. make it blank), check the "rewrite the output of this field", and enter a "[space]" (i.e. a blank character). This works pretty well except for the " - " at the end of the select option when displayed.
Comment #27
TomSherlock CreditAttribution: TomSherlock commentedI don't under comment #25. i have successfully applied the work-around in #16.
I'm using a nodereference with a select list. By applying #16, I no longer see 'title: name' after the field values.
Comment #28
cpall CreditAttribution: cpall commentedI second this, it works fine.
Comment #29
Grayside CreditAttribution: Grayside commented#16 works for me as well.
I suspect that while the title is hardcoded, it does not unset any existing array configuring how to handle the Title field options (for a first use of the Title as a views field). As such, if you mark it as excluded or rewritten (or really any of the options not specifically configured in _nodereference_potential_references_views), they will carry over into the view shown in the widget.
Comment #30
lufecir CreditAttribution: lufecir commented#16 works fine for me too. It's definitely a workaround I can live with. So if it's really a problem to fix this problem at the root, I guess it should at least be documented. A simple additional bullet in the hints when choosing a view as source of the select items would be sufficient. And for those who don't RTFM: well they can still ask google and find this issue. :-)
Comment #31
KarenS CreditAttribution: KarenS commented#16 is the right way to do this.
Comment #33
kiliweb CreditAttribution: kiliweb commentedThanks jlevy, #16 works like a charm !
Comment #34
clashar CreditAttribution: clashar commentedjlevy,
your solution #16 is simple and perfect!
Comment #35
Chris Gillis CreditAttribution: Chris Gillis commented#16 works perfectly.
http://drupal.org/node/230298 Marked as Duplicate
Changing title for better findability.
Thanks jlevy
Comment #36
potassiumchloride CreditAttribution: potassiumchloride commented#16 worked for me too. Thanks!
Comment #37
kaod CreditAttribution: kaod commented#16 didn't work for me but #26 did. I just added the "Node: Title" field and chose "rewrite output" then put a SPACE, like literally hit the space bar and it removed the title from the display.
EDIT: also works by just rewriting the output and inputting nothing in the field, rather than adding a SPACE
Comment #38
newnewuser CreditAttribution: newnewuser commentedI did #16 too. Thanks.
Comment #39
salberto25 CreditAttribution: salberto25 commentedBut only for the title??....I wish to hide any kind of referenced view fields by selecting in the configured fields CCK UI...did I make clear?...