Add node without node/add
Is there a (programmatic?) way to add a node *without* using node/add/something and still gain access to hook_validate(), hook_insert(), hook_update(), and hook_delete()? I'm trying something like this but hook_validate does not seem to fire... function property_menu($may_cache) { $items=array(); // Do not cache this menu item during the development of this module. if (!$may_cache) { $items[] = array( 'title' => t('Review'), 'path' => 'property/create', 'access' => user_access('create property'), 'type' => MENU_LOCAL_TASK, 'weight' => 1, ); } return ($items) } function property_validate($form_id, $form_values) { //validate property number if (!preg_match('/^\d{1,4}$/',$form_values['pnum'])) { //watchdog('security',t('Bad property number entered'), WATCHDOG_WARNING); form_set_error('pnum',t('The property number does not appear to be valid. It should be 3 numbers long.')); } } Thanks! Sean
Hi Sean, You may be interested in the discussion that happened recently on this list: http://lists.drupal.org/archives/development/2008-03/ msg00063.html Ezra Gildesgame On Apr 1, 2008, at 12:05 PM, Sean Wingert wrote:
Is there a (programmatic?) way to add a node *without* using node/ add/something and still gain access to hook_validate(), hook_insert (), hook_update(), and hook_delete()? I'm trying something like this but hook_validate does not seem to fire...
function property_menu($may_cache) { $items=array(); // Do not cache this menu item during the development of this module. if (!$may_cache) { $items[] = array( 'title' => t('Review'), 'path' => 'property/create', 'access' => user_access('create property'), 'type' => MENU_LOCAL_TASK, 'weight' => 1, ); } return ($items) }
function property_validate($form_id, $form_values) { //validate property number if (!preg_match('/^\d{1,4}$/',$form_values['pnum'])) { //watchdog('security',t('Bad property number entered'), WATCHDOG_WARNING); form_set_error('pnum',t('The property number does not appear to be valid. It should be 3 numbers long.')); } }
Thanks!
Sean
I'm trying to build this module http://drupal.org/project/node_factory which seems to be not trivial. It work fine with simple node types without cck or Access Control modules like og. With the discussion mentioned by Ezra B. Gildesgame and some love from some developers I hope to make the module better. On Tue, 2008-04-01 at 09:05 -0700, Sean Wingert wrote:
Is there a (programmatic?) way to add a node *without* using node/add/something and still gain access to hook_validate(), hook_insert(), hook_update(), and hook_delete()? I'm trying something like this but hook_validate does not seem to fire...
function property_menu($may_cache) { $items=array(); // Do not cache this menu item during the development of this module. if (!$may_cache) { $items[] = array( 'title' => t('Review'), 'path' => 'property/create', 'access' => user_access('create property'), 'type' => MENU_LOCAL_TASK, 'weight' => 1, ); } return ($items) }
function property_validate($form_id, $form_values) { //validate property number if (!preg_match('/^\d{1,4}$/',$form_values['pnum'])) { //watchdog('security',t('Bad property number entered'), WATCHDOG_WARNING); form_set_error('pnum',t('The property number does not appear to be valid. It should be 3 numbers long.')); } }
Thanks!
Sean -- Clemens Tolboom build2be KvK NL020994130000
info@build2be.nl http://build2be.nl +31(0)6 10 27 96 95
Node_factory is a great idea for a module as this problem, creating nodes programatically, seems to come up all the time. It'd be great if best practices could be put into node_factory. I used it recently to create a custom module using workflow_ng and node_factory to auto create nodes and it worked great. Kyle On Tue, Apr 1, 2008 at 11:45 AM, Clemens Tolboom <clemens@build2be.nl> wrote:
I'm trying to build this module http://drupal.org/project/node_factory which seems to be not trivial.
It work fine with simple node types without cck or Access Control modules like og.
With the discussion mentioned by Ezra B. Gildesgame and some love from some developers I hope to make the module better.
On Tue, 2008-04-01 at 09:05 -0700, Sean Wingert wrote:
Is there a (programmatic?) way to add a node *without* using node/add/something and still gain access to hook_validate(), hook_insert(), hook_update(), and hook_delete()? I'm trying something like this but hook_validate does not seem to fire...
function property_menu($may_cache) { $items=array(); // Do not cache this menu item during the development of this module. if (!$may_cache) { $items[] = array( 'title' => t('Review'), 'path' => 'property/create', 'access' => user_access('create property'), 'type' => MENU_LOCAL_TASK, 'weight' => 1, ); } return ($items) }
function property_validate($form_id, $form_values) { //validate property number if (!preg_match('/^\d{1,4}$/',$form_values['pnum'])) { //watchdog('security',t('Bad property number entered'), WATCHDOG_WARNING); form_set_error('pnum',t('The property number does not appear to be valid. It should be 3 numbers long.')); } }
Thanks!
Sean -- Clemens Tolboom build2be KvK NL020994130000
info@build2be.nl http://build2be.nl +31(0)6 10 27 96 95
-- Research Assistant eBusiness Center @ BYU kyle.mathews2000.com/blog
I'm looking for a best practice here...I need to store *up to* 20 CCK fields of form input, but hopefully not all on one form. Should I use node/add, then write a .module using hook_form() to request just the first two or three, then redirect the Submit to a series of editing forms (maybe using tabs) for the remainder? I noticed that the New York Observer (http://drupal.org/node/141187) uses 110 CCK fields, though probably not all form input. What's a good practice to collect that data? Thanks! Sean
Did you try drupal_execute()? http://api.drupal.org/api/function/drupal_execute/6 As Ezra said, see the previous discussion thread for the pros and cons to this approach. - Ken Rickard agentrickard On Tue, Apr 1, 2008 at 2:45 PM, Kyle Mathews <mathews.kyle@gmail.com> wrote:
Node_factory is a great idea for a module as this problem, creating nodes programatically, seems to come up all the time. It'd be great if best practices could be put into node_factory. I used it recently to create a custom module using workflow_ng and node_factory to auto create nodes and it worked great.
Kyle
On Tue, Apr 1, 2008 at 11:45 AM, Clemens Tolboom <clemens@build2be.nl> wrote:
I'm trying to build this module http://drupal.org/project/node_factory which seems to be not trivial.
It work fine with simple node types without cck or Access Control modules like og.
With the discussion mentioned by Ezra B. Gildesgame and some love from some developers I hope to make the module better.
On Tue, 2008-04-01 at 09:05 -0700, Sean Wingert wrote:
Is there a (programmatic?) way to add a node *without* using node/add/something and still gain access to hook_validate(), hook_insert(), hook_update(), and hook_delete()? I'm trying something like this but hook_validate does not seem to fire...
function property_menu($may_cache) { $items=array(); // Do not cache this menu item during the development of this module. if (!$may_cache) { $items[] = array( 'title' => t('Review'), 'path' => 'property/create', 'access' => user_access('create property'), 'type' => MENU_LOCAL_TASK, 'weight' => 1, ); } return ($items) }
function property_validate($form_id, $form_values) { //validate property number if (!preg_match('/^\d{1,4}$/',$form_values['pnum'])) { //watchdog('security',t('Bad property number entered'), WATCHDOG_WARNING); form_set_error('pnum',t('The property number does not appear to be valid. It should be 3 numbers long.')); } }
Thanks!
Sean -- Clemens Tolboom build2be KvK NL020994130000
info@build2be.nl http://build2be.nl +31(0)6 10 27 96 95
-- Research Assistant eBusiness Center @ BYU kyle.mathews2000.com/blog
-- Ken Rickard agentrickard@gmail.com http://ken.therickards.com
Thank you both Ezra and Ken! Excellent thread! I'm now reading up using CCK programmatically--very powerful stuff indeed. Sean
Sean Since this question comes up every so often, it would be great if you combine what you read in previous threads, what you learned by doing it, and create a page on Drupal's handbook that captures all this info in one place. It would be useful to many others in the future. On Wed, Apr 2, 2008 at 11:15 AM, Sean Wingert <seanw@norris-stevens.com> wrote:
Thank you both Ezra and Ken! Excellent thread! I'm now reading up using CCK programmatically--very powerful stuff indeed.
Sean
-- Khalid M. Baheyeldin 2bits.com, Inc. http://2bits.com Drupal optimization, development, customization and consulting.
I do agree the problem for creating nodes programmatically arise often. I hope some CCK experts join the issue queue On Tue, 2008-04-01 at 12:45 -0600, Kyle Mathews wrote:
Node_factory is a great idea for a module as this problem, creating nodes programatically, seems to come up all the time. It'd be great if best practices could be put into node_factory. I used it recently to create a custom module using workflow_ng and node_factory to auto create nodes and it worked great.
Kyle
On Tue, Apr 1, 2008 at 11:45 AM, Clemens Tolboom <clemens@build2be.nl> wrote:
I'm trying to build this module http://drupal.org/project/node_factory which seems to be not trivial.
It work fine with simple node types without cck or Access Control modules like og.
With the discussion mentioned by Ezra B. Gildesgame and some love from some developers I hope to make the module better.
On Tue, 2008-04-01 at 09:05 -0700, Sean Wingert wrote:
Is there a (programmatic?) way to add a node *without* using node/add/something and still gain access to hook_validate(), hook_insert(), hook_update(), and hook_delete()? I'm trying something like this but hook_validate does not seem to fire...
function property_menu($may_cache) { $items=array(); // Do not cache this menu item during the development of this module. if (!$may_cache) { $items[] = array( 'title' => t('Review'), 'path' => 'property/create', 'access' => user_access('create property'), 'type' => MENU_LOCAL_TASK, 'weight' => 1, ); } return ($items) }
function property_validate($form_id, $form_values) { //validate property number if (!preg_match('/^\d{1,4}$/',$form_values['pnum'])) { //watchdog('security',t('Bad property number entered'), WATCHDOG_WARNING); form_set_error('pnum',t('The property number does not appear to be valid. It should be 3 numbers long.')); } }
Thanks!
Sean -- Clemens Tolboom build2be KvK NL020994130000
info@build2be.nl http://build2be.nl +31(0)6 10 27 96 95
-- Clemens Tolboom build2be KvK NL020994130000 info@build2be.nl http://build2be.nl +31(0)6 10 27 96 95
Hey Folks (especially perhaps DWW) A module of mine is not getting the green downloads table on the project page. I did make an error in my initial module location in CVS (bad, apologies), but I have since rectified things and created my tags. However, the "Revisions" subtab page for the module still does not pick up any of the module revisions. Any hints on what to do to fix this ? Many thanks Peter Module: http://drupal.org/project/geonames_cck
On Wed, Apr 2, 2008 at 5:33 PM, greenman <greenman@the-organization.com> wrote:
Hey Folks (especially perhaps DWW)
A module of mine is not getting the green downloads table on the project page. I did make an error in my initial module location in CVS (bad, apologies), but I have since rectified things and created my tags. However, the "Revisions" subtab page for the module still does not pick up any of the module revisions.
Any hints on what to do to fix this ?
The usual stuff. Edit the release page, save. Works. (Unless something else made it work in the meantime I edited it :) Gabor
Gábor Hojtsy wrote:
On Wed, Apr 2, 2008 at 5:33 PM, greenman <greenman@the-organization.com> wrote:
Hey Folks (especially perhaps DWW)
A module of mine is not getting the green downloads table on the project page. I did make an error in my initial module location in CVS (bad, apologies), but I have since rectified things and created my tags. However, the "Revisions" subtab page for the module still does not pick up any of the module revisions.
Any hints on what to do to fix this ?
The usual stuff. Edit the release page, save. Works. (Unless something else made it work in the meantime I edited it :)
Gabor
Many thanks. I suppose I should have searched the list archives first. Will be better next time.
I had this issue the other day and hitting edit didn't work. There was some caching mismatch so someone just deleted the entry and it rebuilt it for me. It will update within a few hours if you just let it go otherwise I think. I was able to replicate this the other day though.... On Thu, Apr 3, 2008 at 4:51 AM, greenman <greenman@the-organization.com> wrote:
Gábor Hojtsy wrote:
On Wed, Apr 2, 2008 at 5:33 PM, greenman <greenman@the-organization.com> wrote:
Hey Folks (especially perhaps DWW)
A module of mine is not getting the green downloads table on the project page. I did make an error in my initial module location in CVS (bad, apologies), but I have since rectified things and created my tags. However, the "Revisions" subtab page for the module still does not pick up any of the module revisions.
Any hints on what to do to fix this ?
The usual stuff. Edit the release page, save. Works. (Unless something else made it work in the meantime I edited it :)
Gabor
Many thanks. I suppose I should have searched the list archives first. Will be better next time.
On Wed Apr 2 2008 8:33:54 am greenman wrote:
Any hints on what to do to fix this ?
You should file an issue on d.o and specify Drupal.org infrastructure. -- Jason Flatt http://www.oadaeh.net/ Father of Six: http://www.flattfamily.com/ (Joseph, 15; Cramer, 13; Travis, 11; Angela; Harry, 7; and William, 2) Linux User: http://www.kubuntu.org/ Drupal Fanatic: http://drupal.org/
participants (10)
-
Bryan Ollendyke -
Clemens Tolboom -
Ezra B. Gildesgame -
greenman -
Gábor Hojtsy -
Jason Flatt -
Ken Rickard -
Khalid Baheyeldin -
Kyle Mathews -
Sean Wingert