The CCK (content construction kit) module was released only 2 days ago. I've been working with it for only the past 2 hours, and I'm ecstatic. In terms of its overall usefulness, I'd say its in the same category as simplenews, views, and tinyMCE (read: no drupal developer, consultant, or amature should be without it).
In many ways, this module will likely signal death for flexinode. Which doesn't really bother me, because I never used flexinode. While flexinode still has more 'flexibility' in terms of defining all varieties of different fields, it has serious themability issues which have prevented me from ever using it. Moreover, where as flexinode created something of a pseudo-node type, CCK creates full fledged node types that have all the options, workflows, and permissions levels. But perhaps most exciting is how easy it is to theme your custom fields. To get you started, I've written a quick tutorial on exactly that:
The fields of your content type can be themed in whatever order and fashion you wish. In this example, we've created a Press Release content type with three defined fields named body, subheading, and contactinfo.
Step One: Create a press release template by renaming a copy of your node.tpl.php file to node-content-press_release.tpl.php. Note that all CCK content types follow the same format:
node-content-[the name you gave your content type with underscores in place of spaces].tpl.php
Step Two: Let's say that you wanted the press-release's subheading to appear directly above the body. Here's all you have to do:
Delete everything in between the <div class="content"></div> tags, and replace it with the following:
<h4 class="press-release-subheading"><?php print $node->field_subheading['value']; ?></h4><div class="content"><?php print $node->field_body['value']; ?><h3>Media Contact</h3><?php print $node->field_contactinfo['value']; ?></div>See the pattern? $node->field_"("the name you gave your field")"['value'];
No additional variables are required. Though you should probably use some CSS to style it up.
Comments
CCK $content, nodevote, and custom node template
Haven't done any work with
Haven't done any work with node vote. My guess is that it invokes the node_api (in the same manner as book navigation. Translation -- it seems impossible to get it out of $content without using some asty explode, or preg function (I think php's explode($delimiter, $string) would work).
As for drinking, that reminds me of one of my favorite productivity tips: drink beer late at night while working on open source projects.
Has CCK Changed since you wrote this
<?php print $node->field_field_name[0][view]; ?>for some reason the text field I created is in a multidemensional array rather than as Nick describes above Hopefully this may help somefolk TkgafsThanks Tkgafs. I just
Thanks Tkgafs. I just updated the article to reflect some changes in the way CCK returns variables to the template. Now, you enter: $node->field_example['value'] as opposed to $node->field_example['view'].
I briefly verified this, but let me know if I forgot about something and it isn' working properly.
can you access vocabularies via custom fields
Is there any way to create a custom field on a new content type which can have its values inserted from an existing vocabularysay I create a new content type for playsI would like custom fields for Title, Director, Venue, Year, Castbut these already exist as vocabularies so I dont want to re-type into the defined custom fields, but to choose from the values already existing elsewhereI cant see any way to do this in the module but t may just be my in-experience so any advice anyone could suggest would be most helpful tkgafs
I'd probably use freetagging
I'm trying to do that as well
Thanks for the pointer to
Thanks for the pointer to the php snippet works beautifully !!I now feel I starting to get somewhere. Only have to figure out the category module and my site will be flying, if I ever get the 120 odd plays and couple of thousand actors names typed in. Hopefully the promise of cms's workflow systems will come to my rescue and I can get some other folk to do the drudge work [sorry that really import and and skilfull task] of data input while I concentrate on working out what fool will volunteer to start scanning old programmes and reviews kept in a filing cabinet for the last 40 odd years I'm still having a problem getting tinymce working with cck defined pages but looking at the cck project page I'm not the only one so I'm sure it'll get fixed soon.if anybodys interested have a look at http://cms.dibbletree.com the snippet of code I'm using is below. I'm new to php coding so if anyone can suggest any improvements please let me know. <code><?php if ($terms): ?> <?php $cats = array(); $cats[12] = "Year"; $cats[13] = "Venue(s)"; $cats[11] = "Style"; $cats[14] = "Director(s) "; $cats[15] = "Actors"; $cats[16] = "Actresses"; $var1 = "terms"; $var2 = "term"; $var3 = "lterm"; ?> <div class="terms"> <table><tr> <?php foreach ($cats as $k => $v) { ${$var1.$k} = taxonomy_node_get_terms_by_vocabulary($node->nid, $k); if (${$var1.$k}) { $res = count (${$var1.$k}); print "<td>$v </td><td>"; foreach (${$var1.$k} as $key => ${$var2.$k}) { $res--; ${$var3.$k} = l(${$var2.$k}->name, 'taxonomy/term/'.${$var2.$k}->tid); print ${$var3.$k}; if ($res) { print "|"; } } print '</td></tr>'; } } ?> </table><br> </div><?php endif; ?></code> thanks againtkgafs
wordpress.com i love you!
wordpress.com
i love you!
CCK Download not complete
same problem
I'm having the same problem. The .install files appear to generate the intended sql but for some reason they are not triggering ... not sure how they're supposed to work. Email me scott.trudeau AT gmail DOT com if you figure it out..
no sql file needed
I just downloaded and installed CCK on a 4.7 testbed. No sql file needed or mentioned in the readme. Seems to work fine though I haven't really pushed it much.
additionally
we will be trying to expose a lot of the flexibility that you have with the forms api for views as well.
It all just came together over the conference, and it's going to be fairly spectacular =).
The other guys are very true in saying that you ain't seen nothing yet.
Drupal the Phoenix
Good god man -- its getting ridiculous -- I already noticed hints of change on view and CCK. You know, the Drupal of Dec 05 seems like a boxy, brittle, and inflexible. It takes me 2 hours a day just to keep up with the CVS of the projects! And yet, while that seems like a lot of time, I've found its beginning to save me days of work just to check up on whats happening. I've been building sites since 9am this morning, so I'm brain dead -- but yes -- in keeping with the "meaning" of this time of the year, drupal is having a new beginning -- or rather, drupal has clearly gone phoenix.
tell about differences cck and flexinode
Does CCK work with v4.7 or
I see no reason why it
Fields as prototypes
Actually...
Ahh, CCK!
I hadn't realized JonBob had created a project for CCK until he mentioned it here at the con.
There is a very interesting quartet of work going on here between me, JonBob, clouseau/jvandyk and Vertice/Adrian between Views, CCK, workflow/actions and form API that has some pretty exciting ramifications. All of these systems in place and reliant upon one another should create just sick amounts of flexibility.
Tho CCK with Views support, which you now have (even if you are still limited in types available) is already an amazing step. But I gotta say -- you ain't seen nothin yet. The 'widgets' stuff that we hashed out a bit will take Amazing up an order of magnitude. (Essentially it'll let you define the form items for your field types, which'll give you all kinds of great options about select boxes or customized date fields. Etc. Good stuff).
Post new comment