mapleleaf Posted October 2, 2010 Share Posted October 2, 2010 I have just opened up Drupal and need to add a form that gets processed to one of the existing pages. All the form layout and processing are ready. I just need some help in how one fits this into Drupal. Custom theme? New page template? Seems too much php to add as a PHP snippet in the page editor. Any thoughts much appreciated. Quote Link to comment Share on other sites More sharing options...
phpfreak Posted October 3, 2010 Share Posted October 3, 2010 You can do it the drupal way or you can do it your own way. I've found that doing anything with drupal's forms requires learning. If you have the views module installed you can create a new view, or hack your template and add a menu path and include a template file with your PHP code, or just make a "form.php" file and process your own forms. Drupal usually has jquery built in with Ajax support, but you can grab the jquery.form plugin and use Ajax Forms and then post to your own form.php. From there, I do a bootstrap and then map your $node->filed = $_POST['value']; and do a node_save($node); and then display a message to the user. Quote Link to comment Share on other sites More sharing options...
phpfreak Posted October 3, 2010 Share Posted October 3, 2010 one thing to note is that if you're bootstrapping a file in drupal, you should put the file at the same root path as your index.php - otherwise you'll have bootstrap nightmares. For example: public_html/index.php public_html/forms.php Inside forms.php set_include_path($_SERVER['DOCUMENT_ROOT']); require_once $_SERVER['DOCUMENT_ROOT'].'/includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); And now you have full access to drupal's database layers, user authentication, and all of drupal's classes and modules. You can process your form and save the data into an object and node_save that object. There's also node_submit and a few other functions for validation. I recommend http://drupal.org for more on that stuff. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.