I needed an extra checkbox along with Promote, Publish, etc. on the content type form, so used node_form_FORM_ID_alter to accomplish that. Now, if that box is checked, when content of that type is created I need an additional box in the same section. My problem is that the node form doesn't seem to have that field present from the content type form for me to interrogate. So I either should not have used the original hook to add the field to the content form, or I should be hooking something else in order to get that field added to the #node section of the node form. There are SO many new functions and hooks ... if there is a page with a graphic that lays out the flow nicely, or some narrative or good example module from which I can glean the answer, please tell me :) Jeff
Still unclear on this...not for lack of searching. If I add a field to node_type_form with hook_form_alter, how do I access that field's contents when NOT on the content type page? For example, if as a result of hook_form_alter my content type form shows the following: Default options Published Promoted to front page Sticky at top of lists Create new revision My option The setting for My options shows up every time I edit the content type, but how do I access it when content is being created for that content type?
hook_nodeapi using op load or prepare. Alternatively you could use my module http://drupal.org/project/custom_pub but it doesn't have a per node_type customization at the moment. But if nothing else the code will show you how I accomplished it. ----- Adam A. Gregory Drupal Developer & Consultant Web: AdamAGregory.com Twitter: twitter.com/adamgregory skype: aagregory2 Phone: 661.347.6597 On Tue, Jun 28, 2011 at 6:25 PM, Jeff Greenberg <jeff@ayendesigns.com>wrote:
** Still unclear on this...not for lack of searching. If I add a field to node_type_form with hook_form_alter, how do I access that field's contents when NOT on the content type page? For example, if as a result of hook_form_alter my content type form shows the following:
Default options Published Promoted to front page Sticky at top of lists Create new revision My option
The setting for My options shows up every time I edit the content type, but how do I access it when content is being created for that content type?
Hi Adam. Hook_nodeapi was put out to pasture in D7, wasn't it? I'm at the point of node/add/whatever_type, so hook_node_prepare applies, but the $node object for it contains only the standard fields and fields added to the content type, but not fields added to the content type form. I don't know if I'm explaining it correctly. I want to be able to add an option to content types that can be used or not, and then when creating a piece of content, be able to check whether that content type is supposed to use that option.
hook_nodeapi using op load or prepare. Alternatively you could use my module http://drupal.org/project/custom_pub but it doesn't have a per node_type customization at the moment. But if nothing else the code will show you how I accomplished it. ----- Adam A. Gregory Drupal Developer & Consultant Web: AdamAGregory.com Twitter: twitter.com/adamgregory <http://twitter.com/adamgregory> skype: aagregory2 Phone: 661.347.6597
On Tue, Jun 28, 2011 at 6:25 PM, Jeff Greenberg <jeff@ayendesigns.com <mailto:jeff@ayendesigns.com>> wrote:
__ Still unclear on this...not for lack of searching. If I add a field to node_type_form with hook_form_alter, how do I access that field's contents when NOT on the content type page? For example, if as a result of hook_form_alter my content type form shows the following:
Default options Published Promoted to front page Sticky at top of lists Create new revision My option
The setting for My options shows up every time I edit the content type, but how do I access it when content is being created for that content type?
If you are adding that option into $form['workflow']['node_options']['#options'], then you can access it by checking: if (in_array('myoption', variable_get('node_options_' . $node->type, array('status', 'promote')))) { // Do something. } Dave Reid dave@davereid.net On Tue, Jun 28, 2011 at 8:25 PM, Jeff Greenberg <jeff@ayendesigns.com>wrote:
** Still unclear on this...not for lack of searching. If I add a field to node_type_form with hook_form_alter, how do I access that field's contents when NOT on the content type page? For example, if as a result of hook_form_alter my content type form shows the following:
Default options Published Promoted to front page Sticky at top of lists Create new revision My option
The setting for My options shows up every time I edit the content type, but how do I access it when content is being created for that content type?
On Wed, Jun 29, 2011 at 3:25 AM, Jeff Greenberg <jeff@ayendesigns.com> wrote:
Still unclear on this...not for lack of searching. If I add a field to node_type_form with hook_form_alter, how do I access that field's contents when NOT on the content type page? For example, if as a result of hook_form_alter my content type form shows the following:
Default options Published Promoted to front page Sticky at top of lists Create new revision My option
The setting for My options shows up every time I edit the content type, but how do I access it when content is being created for that content type?
Hi Jeff, try to check here, the nodeapi_example for D7: http://drupal.org/project/examples P. -- Paolo Mainardi CTO Twinbit ILDN: http://www.ildn.net Blog: http://www.paolomainardi.com -- Please consider the environment before printing this email --
The process of creating an option for use in other content types is one of the first coding examples in "Pro Drupal 7 Development", Chapter 2. Sincerely, -Blake bsenftner@earthlink.net www.BlakeSenftner.com www.MissingUbercartManual.com www.Droplabs.net On Jun 28, 2011, at 6:25 PM, Jeff Greenberg wrote:
Still unclear on this...not for lack of searching. If I add a field to node_type_form with hook_form_alter, how do I access that field's contents when NOT on the content type page? For example, if as a result of hook_form_alter my content type form shows the following:
Default options Published Promoted to front page Sticky at top of lists Create new revision My option
The setting for My options shows up every time I edit the content type, but how do I access it when content is being created for that content type?
Thanks, all, for your help with this. All the assistance was spot-on, the code example and the pointers to the book example and the example module, which I repeatedly forget to consider first, despite my amnesia's having burned me a few times!
participants (5)
-
Adam Gregory -
Blake Senftner -
Dave Reid -
Jeff Greenberg -
Paolo Mainardi