Looks like crud.inc contains the ability to programmatically create node types, but not the associated CCK fields. This would be a nice addition.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | crud_patch1.txt | 9.87 KB | sime |
| #5 | more.crud_.inc_.txt | 6.47 KB | sime |
Looks like crud.inc contains the ability to programmatically create node types, but not the associated CCK fields. This would be a nice addition.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | crud_patch1.txt | 9.87 KB | sime |
| #5 | more.crud_.inc_.txt | 6.47 KB | sime |
Comments
Comment #1
boris mann commentedCCK is hard to build programmaticaly. And by "hard", I mean it can't be. But yes, definitely want to do this....
Comment #2
dmitrig01 commentedaccording to http://groups.drupal.org/node/5272 it's now possible
Comment #3
moshe weitzman commentedprogrammatically adding/editing the fields for an existing type is still quite brittle
Comment #4
simeHi, maybe this is useful. Here is the code I'm using. Without any doubt, it's not pretty using functions like
_content_admin_field_add_new_submit(). I just passed this code to someone in IRC, so I will update if it proves effective for someone else.Comment #5
simeI've got a bunch of functions here. I also have some node creation code which is fairly easy to use, but it's not quite right yet.
Here is a list of functions in the attached file.
install_create_content_type()
install_create_field()
install_add_existing_field()
install_create_field_group()
install_fields_in_group()
install_add_vocabulary()
install_add_term()
install_assign_nid_tid()
Thanks for review.
Comment #6
dmitrig01 commentedI'll commit this after some update to the phpdoc - thanks
Comment #7
simeTo anyone trying the above. install_create_field is a bit screwed. a better version (and better commenting) will come.
Comment #8
simeHere is the patch for the new functions, I've tried to make it squeeky clean. I've been testing the new patch while developing profiles and it seems ok.
This patch doubles the size of crud.inc. It might be worth branching DRUPAL-5 and tagging the current version.
Comment #9
simechanging status.
Comment #10
simeI have a feeling this is not high priority, perhaps I should just move it into my install profile... any opinion?
Comment #11
moshe weitzman commentedseems useful to me and is worthy of commit
@sime - if you can, take a look at HEAD CCK and its content_crud file. It has expanded a lot, and includes most of this functionality. maybe you can help it grow even more.
Comment #12
simeThanks. Had a quick look at content_crud, and yes this deserves some thought...
Comment #13
simeAhh. Having brushed away the cobwebs of my mind, I recall now looking into this, looong ago, and I remember why I chose to focus on install_profile_api instead.
If I write a function for this install_profile_api, there is an implicit assumption that it will only be used during installation. Designing a function for installation is much easier than for ongoing use, because if it doesn't work you simply start from scratch or you choose not to use it - you don't have much to lose, you have a lot to gain.
If it goes into cck crud, then the expectation is that it should work in any live environment. Here you have a lot to lose.
For example, my "create content" function (not in the patch as it's a bit flaky) breaks if you have pathauto enabled. In a live site it's not really appropriate to disable pathauto for the purpose of programmatically adding content. In an install_profile, my goal is make things easy as much as possible, but shortfalls like pathauto can be fixed post install.
I know that the pathauto problem can be overcome. However, the point is you don't really know what might be enabled and triggered by node creation - unless you control everything (as in an install profile).
Comment #14
boris mann commentedIf I could assign this to someone other than myself, I would :P
This is good and important and it needs to go in.
Comment #15
simeLooks like it's my baby for a bit. Thanks Boris.
I've branched DRUPAL-5 where I'll add the new functions.
DRUPAL-5--1-0 is the code /before/ my additions. HEAD is currently same as DRUPAL-5--1-0 so no-one gets a shock.
If people wish to work with DRUPAL-5 branch that I'm patching, the existing API will not change.
The one possible gotcha is that install_add_content_type() is now a wrapper for the next generation version install_create_content_type(). Any backward compatibility issues, please let me know.
I'm currently working with Lonely Planet project with this code, and hope to improve it over the next few weeks.
Ta
.s
Comment #16
simehttp://drupal.org/cvs?commit=90423
Comment #17
boris mann commentedThanks, sime, welcome aboard! I think I've got a bunch more projects that are going to need install profiles built, so I hope to put some serious dev time into this. Unless Adrian just decides to fix the whole thing :P
Comment #18
simeThanks Boris. Yeah, I'm definitely watching Adrian's dev emails with interest!
Comment #19
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #20
rubymuse commentedApologies in advance: my first post ever, and no doubt in over my head. Do I understand correctly that the CCK field type creation functions are available in crud.inc, but are not generated by the profile wizard? Any plans for that? Thanks!
Comment #21
boris mann commentedHi rubymuse -- you are correct -- please open new issues if the current one is closed. The Profile wizard is languishing a bit, and needs things like automatic capture of CCK types. Please open a new issue for that against the profile wizard -- that would be an excellent add on.
Comment #22
jhedstromThis should be more readily available from the Install Profile API page. The only way to currently download it is directly from CVS.