Closed (fixed)
Project:
Panels
Version:
6.x-3.7
Component:
Documentation
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
16 Jul 2010 at 09:26 UTC
Updated:
7 Feb 2012 at 23:23 UTC
Jump to comment: Most recent file
Hello,a question about Panels and CCK.In panels,I set Selection rules as 'Node:Type',then I make a layout and some regions,then I put a 'New custom content' in one of these regions.In the form,I can input some keywords,right?But the problem is,there is no CCK field keyword in the keyword list,it has %node:uid,%node:title,but no cck field.How can I add a CCK field as the keyword?
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 0002-Token-and-CCK-conditions-for-additional-descriptions.patch | 3.57 KB | itangalo |
| #12 | 0001-Token-and-CCK-conditions-for-additional-descriptions.patch | 4.65 KB | itangalo |
| #10 | 856050-field-token-docs.patch | 3.62 KB | merlinofchaos |
| #9 | custom-description.png | 6.49 KB | itangalo |
| #9 | field-token-docs-custom.patch | 732 bytes | itangalo |
Comments
Comment #1
AvalancheOfLlamas commentedYou can add a CCK field to a pane under Add Content -> Node -> Field:[your field name]. Adding it as a 'keyword' would require CCK fields to be able to be used as context though, which is a feature I've been looking for too.
But say you want some custom content in with that field? A solution to this problem for now is to use a view.
First, create a view that filters by your node type (and published nodes only, perhaps).
Then, add your CCK field to the view's fields.
Next, add an argument for Node:Nid, and optionally, add in whatever settings you want for the title/breadcrumb.
Add a 'content pane' display (this assumes you have the module on that lets you add them) to the view, and click on it.
Under 'Pane Settings,' next to 'argument input' click Edit.
You should see Node:Nid Source, and in that select list, go to 'From Context'.
Under the 'Required Context' select list, find 'Node ID'.
Leave the checkbox unchecked, since your panel is already filtering for Node Type, you'll always have the Node ID context available.
Update and save the view if you haven't already.
Now, you can theme your CCK field. Click on the field you're using, and find the "Rewrite the output of this field" checkbox. Select it, and in the text box below, you can add in HTML and custom content, using the replacement tokens for your field. You can even add more CCK fields and combine content in this way. Update it and save.
In your panel, add this to your content by going to Views -> View Panes. The settings will ask you where you want to get your Node ID from, and you should just stick with the node being viewed.
Hope that helps!
Comment #2
merlinofchaos commentedIf you install token.module I believe all or at least most CCK fields get added as toekns.
Comment #3
clem.chuang@gmail.com commentedThank you,I will try it.
Comment #5
itangalo commentedTokens does not provide any CCK field keywords in Panels, and Panels (as of 3.7) does not have support for CCK fields as keywords or contexts.
Changing category to feature request.
Comment #6
Josh Benner commentedThis works in panels. If you have a text field called 'my_text_field', make sure you have a node context available, then you can do something like this:
%node:field_my_text_field-raw
or
%node:field_my_text_field-formatted
The only real issue is that these tokens are not shown in the list of available keyword replacements displayed by Panels.
Comment #7
itangalo commentedI stand corrected. Thanks for pointing this out!
Comment #8
merlinofchaos commentedWe can't really help that they aren't shown in the token list, unfortunately, but we can attempt to document this.
Comment #9
itangalo commentedNow don't be harsh on me, because I'm not a coder. But I tried to add some help text in Panels/Ctools to make it visible to users that CCK fields can be used as keywords.
I made this change on two places:
1. Where you add a custom content pane, as a description to the checkbox Use context keywords.
2. As a description in the Summary of contexts list on the context configuration tab. This required altering the theme_ctools_context_list function to include a description term (or at least that was my conclusion).
I know that altering a theme function like this may be disputable, but it seemed that all kind of logic and processing went on inside it -- and adding a description in another way would be difficult. Hopefully the attached patches can make it easier to decide whether my approach is ok or should be thrown out the window.
The first patch is much more straight forward, and the only reason to disregard it would be that not all sites (and all contexts!) use CCK fields. On the other hand, having the information at hand hurts noone, and CCK is kind of standard.
Two images are attached to show what the changes look like for users.
Comment #10
merlinofchaos commentedA single patch is easier to apply, but otherwise the patches are well formed. THe code changes are okay, but there's one minor problem: The text is only true if token.module is installed. Now, the good news is that token.module is installed on most sites. But not all sites, so we need to take that into account.
Here's a single patch to make it easier to reroll.
Comment #11
itangalo commentedYay!
Comment #12
itangalo commentedOk, here's an updated patch with the additional description texts conditioned on CCK and Token being enabled. (I also took the liberty to add a description text if Token was *not* enabled, telling the user that Token would make more keywords available.)
I created this single patch using some tool I found, learning as I am. I hope it works with the standards on d.o.
Cheers!
Comment #13
itangalo commentedComment #14
merlinofchaos commentedThe patch applied, though it needed a -p1 rather than the usual -p0. I can cope with that.
What tool did you use and what platform? We've been struggling to find something that can generate patches for Windows. Though it looks like this created a patch via git?
(Patch committed, btw)
Comment #15
itangalo commentedGlorious day! I had a patch committed into Panels!
Sorry about the -p1, I'll have to check out how to change that.
The tool I used was Giggle, a Git GUI tool for Linux (http://live.gnome.org/giggle). Don't know much about Git + Windows, sorry. :-(
Comment #17
dave reidThe patch that was committed to HEAD still needs work. It mentions the content.module and only says real tokens are only available if token.module is installed. The token API is provided by core, so works by default. Only token.module in contrib is required for using theme('token_help') for a browsable token UI.
Comment #18
itangalo commentedI'm on it. It'll take a few more days before I get anything committed, so if anyone is in a rush feel free to beat me to it. (I'll check this thread before I start a new patch.)
@Dave Reid: Thanks for pointing out the miss.
Comment #19
itangalo commentedThe description texts now contains the following information:
* If CCK and Token is enabled: Use this-and-that format to insert CCK keywords.
* If CCK (but not Token) is not enabled: You will have CCK keywords available if you install Token.
* Else: Description texts unchanged.
Note: The CCK tokens/keywords *only* works if the Token module is enabled. (I've tested and confirmed this.)
Cheers!
PS: I am tempted to change the project into ctools, since the patch applies to that project. But I guess it would cause more confusion than it mitigates.
Comment #20
itangalo commentedTest bot, please review!
Comment #21
merlinofchaos commentedSadly no test bot for any of my modules. =)
Comment #22
itangalo commentedIn release 1.8 of ctools!
*celebrating*
Comment #23
deleuje commentedBefore applying the patch here I was not able to use CCK supplied tokens within Panels.
I wanted to note it so other people won't go nuts like me thinking they may be the only ones unable to use these available but undocumented tokens.
Comment #24
pierremarcel commentedI just checked the thread given by the deleuje comment #23 and the patch provided on comment #17 works great! Hey deleuje thanks for posting that link!
Comment #25
Michsk commentedIs there a way to use %node:field_name-formatted and get a filefield path to a image? Then i can just run it trough imagecache to display the proper image. But i just can't get anything -raw doesn't return me nothing either.
Comment #26
itangalo commented@Iasac: Not that I know of. :-/
Comment #27
Michsk commentedyeh i eventually went with a node_load, doesnt look like images work