I have a node storing details of a book, with fields for the book title, author, ISBN and price. I can insert the title easily, eg. [node:book22 title], but I'd like to be able to insert data from other fields, such as the price, eg. [node:book22 price] where "price" is the price field. This may straightforward for certain field types (text, integer, date), but could be problematic for more complex field types.

A useful option would be to be able to specify a span class for the data. eg. <span class="cash">[node:book22 price]</span>

Comments

AlexisWilke’s picture

iantresman,

Would something like [node:book22 cck=price] work for you? That way we can make sure that there is no clash with the name of the field. As for how to render the field, there are theme(...) calls we can do to make that work.

Thank you.
Alexis Wilke

iantresman’s picture

The syntax doesn't matter, but [node:book22 cck=price] would be fine. And I assume that theming is optional.

AlexisWilke’s picture

iantresman,

Okay, there is a first version checked in. You should see the -dev change to Aug 8, test that version and see what it does.

Note that there is no reason for me to directly render the raw data. Plus, the raw data can really be anything so I don't see how I could do that...

But of course, you are free to have a look and submit a patch for even more extended support.

IMPORTANT: The syntax requires a semicolon as in:

[node:book22 cck=price;]

Otherwise the '=value' does not take.

Thank you.
Alexis Wilke

AlexisWilke’s picture

Assigned: Unassigned » AlexisWilke
Status: Active » Fixed

This supports any CCK type.

The display follows whatever is defined in the CCK display setup area.

Thank you.
Alexis Wilke

iantresman’s picture

Wow that was quick, I'll check it out tomorrow as I'm away all day today.

Status: Fixed » Closed (fixed)

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

iantresman’s picture

Status: Closed (fixed) » Active

I've created a new content type for books, and added one new field "cost" which holds a decimal value.
The following works fine:
Item: [node:* cck=title;]

However:
Item: [node:* cck=cost;]
give a warning message:

Node #62 is being inserted twice by InsertNode. Breaking the recursive loop here.

iantresman’s picture

An interesting following on. I have defined a node #100 with one new CCK field "cost", contain the following:

Title: [node:* cck=title;]
Cost: [node:* cck=cost;]

If I include this node in another (eg. node #200) by adding [node:100] then:

  • I see the title from node #100
  • I see the cost added to the parent node #200

I still get the error message above, but the behaviour is different. In the "cost" example, node #100 is working like a "macro", because it gets its data from the parent of the inserted note. This is powerful. I could create a "Paypal Button" node, and insert it into another node, to display the button with the parent node's data. Brilliant!
But it is odd that "cck=title" is not working in the same way, and does not appear to show the parent node's title, but the inserted node's title.

The ability to create node "macros" would be extremely powerful, and looks just a step away.

AlexisWilke’s picture

iantresman,

I think that if you have the "recursive" error showing up, then you probably get the error when inserting the data the first time. Then the result it gets parsed again as if part of the parent node instead of the child node.

More or less, if you want to create a macro, it seems to me that you would need to not have the filter on the node being inserted (node with id 100.)

I will test to see whether what I'm saying here makes sense. But * is the current node and thus it would always be the "parent" most (or root) node and that is what I use for both, a standard CCK field and the "cck=title;" field.

Finally, it seems to me that the cost field should be referenced as: field_cost and not just plain cost.

[node:* cck=field_cost;]

Thank you.
Alexis

AlexisWilke’s picture

Status: Active » Fixed

iantresman,

Did the field_cost resolve your problem?

At this point, I'll mark this issue as fixed. If you still have a problem, let me know.

Thank you.
Alexis

Status: Fixed » Closed (fixed)

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