A node type (A) is set up using CCK that contains a node reference to another content type (B). When creating a pathauto rule for node type A, using the title of referenced node type B does not work (it just appears to be blank). However using the nid of B in the path of A does work.

CommentFileSizeAuthor
#14 312349.patch1.24 KBezra-g
#7 content.token_.inc_.patch951 bytesjustafish

Comments

greggles’s picture

Title: titles for node references don't work » token for titles for node references don't work
Project: Pathauto » Content Construction Kit (CCK)
Version: 6.x-1.1 » 6.x-1.x-dev
Component: Code » nodereference.module

This is probably a token/cck bug, not a Pathauto bug.

If you could provide more details (the pattern you used, the expected URL, the actual URL) that would be helpful.

yched’s picture

Status: Active » Fixed

I'd bet this is because the noderef field is set to be hidden in 'full node' view.

We just added a way to separate the display settings for tokens
Get latest CCK 6.x-2.x-dev (er, maybe wait another day for the package to be rerolled with today's commits.
Be sure to run update.php
Visit the 'Display fields' tab for the content type - set the display settings for 'Token' (1st choices for all fields should be what you want)

Please reopen if the problem persists.

justafish’s picture

Status: Fixed » Active

The noderef field isn't hidden in full node view, I haven't even touched the display settings of any fields I've made in fact.

The pattern I have in my pathauto settings is:
[term-raw]/awards/[field_award_reference-title]

The output I'm getting is
<term>/awards
<term>/awards-0
etc

if I change it to
[term-raw]/awards/[field_award_reference-nid]

then it works, I get <term>/awards/<nid of referenced node>

I haven't tried your suggestion yched as the field isn't hidden as you suggested, so let me know if you still want me to try it.

justafish’s picture

Project: Content Construction Kit (CCK) » Token
Version: 6.x-1.x-dev » 6.x-1.11
Component: nodereference.module » Code

just had exactly the same problem using Automatic Nodetitles. The nid works but the title doesn't. I guess this is a token problem then.

greggles’s picture

Project: Token » Content Construction Kit (CCK)
Version: 6.x-1.11 » 6.x-2.x-dev
Component: Code » nodereference.module

The token implementations for cck are in the cck module.

justafish’s picture

It appears that the $object that's passed to the function nodereference_token_values (content.token.inc, line 70)
only contains 'nid' and 'error_element' (and sometimes '_weight'). I would assume that the node referenced isn't being loaded, with the nid value coming from the value of the reference field, but maybe someone more enlightened has more to say on that?

justafish’s picture

Assigned: Unassigned » justafish
Status: Active » Needs review
StatusFileSize
new951 bytes
greggles’s picture

@justafish - thanks for this patch and good detective work finding the cause. I think it would be better from a performance standpoint to use a custom query that just loads the necessary elements rather than a full node_load which can be quite slow.

Maybe that's not entirely possible due to the $node->view element...

liquidcms’s picture

not sure anyone cares at this point.. but this is also broken in D5

greggles’s picture

not sure anywhere cares

Seriously?

Of course people care. There are many competing priorities for attention and this issue is one of them.

Further, there is a patch on this issue! Did you try it? Could you review it?

liquidcms’s picture

well at first glance i wuold have to say the patch won't worl to well for Dr5 since cck doesn't have a content_token.inc file; but this morning i seem to be thinking a little clearer; there is a token_cck.inc in the token module - i'll try the changes there and commit a patch on that module if they work.

liquidcms’s picture

or perhaps you meant this: http://drupal.org/node/222214 and that there was a patch already. lot of changes in that patch; i guess i should be using that - all i did was apply the changes from the patch here to the token_cck.inc file and they seem to work; but perhaps it doesn't work as well as i think??

aquila’s picture

I am seeing quite similar behaviour with referenced nodes, but it seems more complicated. Referenced nodes work, but nodes referenced by referenced nodes do not, although they are shown in the possible tokens box. Should I submit a new bug or add it to this one?

ezra-g’s picture

StatusFileSize
new1.24 KB

The patch in #7 no longer applies. Attached is a re-roll. I added a title-raw token missing in the earlier patch and I kept the node_load, though greggles makes a good point that we should avoid that if it's possible.

sirkitree’s picture

Thanks, applies and works for me.

marcp’s picture

The patch above worked great for me -- fixed my auto node titles that had HTML entities in them from nodereference titles.

There's mention above, and in the patch, of $node->view. That looks like it'd be something valid, but I can't seem to figure out what that's supposed to be (views compatibility?).