| Project: | Content Construction Kit (CCK) |
| Version: | 6.x-2.1 |
| Component: | General |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
This follows an IRC discussion with Eaton, who pointed that contrib modules like nodeasblock (probably not the best example, no D6 port yet...) might want to expose their own 'build modes' and let them have specific field display settings. It also occurred to me that this could fix #153561: other modules cannot access <hidden> CCK fields (mainly translates as "hiding a field in 'full node' breaks token generation).
Attached patch allows contrib modules to expose their additional render modes through hook_content_display_contexts(). Functions naming could probably be enhanced a little, but you get the idea.
To avoid overcrowded 'Display fields' screens, each module gets its own separate tab. See screenshots in followup.
| Attachment | Size |
|---|---|
| cck_display_contexts.patch | 7.68 KB |
Comments
#1
Screenshots.
#2
Outstanding enhancement.
#3
Subscribe - agreed, seems pretty handy to me.
We'll also need to change the token API hook_token_values to take this into account, but that can be a separate issue.
#4
This is really, really nice. Mega +1.
#5
One more thought - token module probably shouldn't implement hook_content_display_contexts - instead any module that uses token should. That way users can control the fields for Pathauto vs. Auto Nodetitles.
#6
greggles : I don't think I'm in favor of this :
- means that the same token can generate different things based on where you paste it - will confuse people IMO.
- means that a module cannot use tokens unless it implements this CCK-specific hook
I think we need at least a generic 'token' display context. Then if pathauto or auto_nodetitle want to add their own, (and hook_token_values supports it), they can do it later.
I need to make sure they can add them under the 'Token' sub tab of 'Display fields', though
#7
That's fine. After discussing this more in IRC I think you are right that there should just be the one token_content version.
#8
greggles : OK.
One interesting feature would be to let those additional display modes be used in Views' node row style (alonng with current 'full' and 'teasser').
But not all of them are interesting (RSS, search index, token...), so I need to let the contexts be 'flagged' as 'display in Views' before freezing the expected format for hook_content_display_contexts().
#9
This looks very useful. I'm all for it but haven't had time to try it out.
#10
New patch as per my comment in #8 : open the way to plug into Views' 'node' row style (not actually implemented yet - whether this would go in Views or in CCK can probably be discussed).
I also renamed the functions a little to be more consistent with core's terminology ('build mode' instead of 'display context')
I'm not too happy with the return format for hook_content_build_modes(), but that's the best way I could find to organize the info we need.
#11
Committed.
I guess this needs to be documented somewhere... Not sure where, though.
hook_content_build_modes() is part of 'CCK API not targeted to field modules'
The only other function in this API would be hook_content_extra_fields()...
#12
How about using Advanced help to document this?
#13
I do think it should be somewhere in the online handbook, so that we can point to it in the issue queues.
This being said, it definitely should have a page in advanced help - so would the content of cck/theme/README.txt
But I'm going on vacation tomorrow and won't be able to tackle this myself before another 3 weeks.
More generally : anyone is welcome to help enrich the advanced_help pages. No irony, really, but a frank invitation :-)
#14
Automatically closed -- issue fixed for two weeks with no activity.
#15
There is something I'm not getting right, I guess.
I've followed this thread because my CCK tokens in Automatic Node Titles had stopped working without me switching any visibility toggles (below I provide an explanation of what I'm trying to achieve). So this thread explained to me what had changed in the new release of CCK. I set my field's visibility option for Token to "Text", since "Default" wasn't working. Nothing. I cleared cached data, to no avail.
If anyone has any idea of what I'm doing wrong, please enlighten me...
Explanation of what I'm trying to achieve
I have two custom content types, both of which serve as user profiles:
The profile content has a field called field_fullname, which I used to be able to call as a token for auto node title creation, from both content types, so that the titles would be "Profile for XXXX" and "Menu for XXXX". Not anymore.
#16
Alright, I realized my delusion in thinking that I could access the profile CCK field from the menu content type. The whole thing actually works, except I was trying to do something that made little sense.
I'm closing this thread again.