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?

Comments

AvalancheOfLlamas’s picture

You 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!

merlinofchaos’s picture

Status: Active » Fixed

If you install token.module I believe all or at least most CCK fields get added as toekns.

clem.chuang@gmail.com’s picture

Thank you,I will try it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

itangalo’s picture

Version: 6.x-3.5 » 6.x-3.7
Category: support » feature
Status: Closed (fixed) » Active

Tokens 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.

Josh Benner’s picture

Category: feature » bug

This 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.

itangalo’s picture

I stand corrected. Thanks for pointing this out!

merlinofchaos’s picture

Title: How to make a CCK field as a keyword? » Document CCK tokens that are not shown in token list
Component: Panel nodes » Documentation
Category: bug » task

We can't really help that they aren't shown in the token list, unfortunately, but we can attempt to document this.

itangalo’s picture

Status: Active » Needs review
StatusFileSize
new752 bytes
new658 bytes
new15.86 KB
new732 bytes
new6.49 KB

Now 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.

merlinofchaos’s picture

Status: Needs review » Needs work
StatusFileSize
new3.62 KB

A 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.

itangalo’s picture

Yay!

itangalo’s picture

Ok, 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!

itangalo’s picture

Status: Needs work » Needs review
merlinofchaos’s picture

Status: Needs review » Fixed

The 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)

itangalo’s picture

Glorious 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. :-(

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dave reid’s picture

Status: Closed (fixed) » Needs work

The 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.

itangalo’s picture

Assigned: Unassigned » itangalo

I'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.

itangalo’s picture

The 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.

itangalo’s picture

Status: Needs work » Needs review

Test bot, please review!

merlinofchaos’s picture

Sadly no test bot for any of my modules. =)

itangalo’s picture

Status: Needs review » Closed (fixed)

In release 1.8 of ctools!
*celebrating*

deleuje’s picture

Before 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.

pierremarcel’s picture

I 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!

Michsk’s picture

Is 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.

itangalo’s picture

@Iasac: Not that I know of. :-/

Michsk’s picture

yeh i eventually went with a node_load, doesnt look like images work