The following PHP is what I have in a page.tpl.php, and it worked before I upgraded Drupal 6.14 to 6.19 and enabled clean URLs (with Pathauto).
Now when I submit a profile edit, the page just reloads quickly, but nothing is written to the database. Anyone know why? Need more info? Thanks!
<?php global $user; // if the user is logged in if ($user->uid > 0) { module_load_include('inc', 'user', 'user.pages'); profile_load_profile($user); print(drupal_get_form('user_profile_form', $user, 'Personal Information')); } else { // do something else } ?>
OLD CODE...
<?php /* global $user; $uid = $user->uid; if ($uid > 0) { include_once drupal_get_path('module', 'user') . '/user.pages.inc'; // print(drupal_get_form('user_profile_form', $user)); profile_load_profile($user); // var_dump($user); print(drupal_get_form('user_profile_form', $user, 'Personal Information')); } */ ?>
Maybe someone else has an idea why the code itself doesn't work. But if you'll pardon my presumption, I'm not sure there's ever a situation where you should be putting code like this in page.tpl.php. Maybe with more information someone could suggest an alternative, more "best practice" method for achieving your desired result.
For example: if I want to arbitrarily place form content on some page of my choice, I'd use panels.
And failing that-- if you really can't find a tool like panels that does what you want, then write a custom module to do it. For example:
mymodule.module:
mymodule_menu(){ $items = array();
$item['my/custom/page'] = array( 'title' => t('Title of my page'), 'page callback' => 'drupal_get_form', 'page arguments' => 'user_profile_form', 'access arguments => array('permission the user has to have'), ... ); return $items; }
This code, once the module is enabled and all the cache is cleared, should put the form you want on the path you just named. If you want it in a block, then decalare block content in your module instead of a menu entry, and place the block into a region.
On 09/03/2010 04:16 PM, Kevin Davison wrote:
The following PHP is what I have in a page.tpl.php, and it worked before I upgraded Drupal 6.14 to 6.19 and enabled clean URLs (with Pathauto).
Now when I submit a profile edit, the page just reloads quickly, but nothing is written to the database. Anyone know why? Need more info? Thanks!
<?php global $user; // if the user is logged in if ($user->uid > 0) { module_load_include('inc', 'user', 'user.pages'); profile_load_profile($user); print(drupal_get_form('user_profile_form', $user, 'Personal Information')); } else { // do something else } ?>
OLD CODE...
<?php /* global $user; $uid = $user->uid; if ($uid > 0) { include_once drupal_get_path('module', 'user') . '/user.pages.inc'; // print(drupal_get_form('user_profile_form', $user)); profile_load_profile($user); // var_dump($user); print(drupal_get_form('user_profile_form', $user, 'Personal Information')); } */ ?>
global $user; in a template file wasn't my idea, but the previous developer's. Took over this project.
I would like to use panels, but I can't figure out how to create a panel page with the profile edit form in there. Anyone know how?
Can anyone also explain why the user-profile-form would "save" when clean URLs are turned off (/?q=as/22), and then it doesn't save when clean URLs are turned on (/as/22)?
<form action="/as/22" accept-charset="UTF-8" method="post" id="user-profile-form" enctype="multipart/form-data">
Thank you,
Kevin
On Sep 3, 2010, at 13:41 PM, Christopher M. Jones wrote:
Maybe someone else has an idea why the code itself doesn't work. But if you'll pardon my presumption, I'm not sure there's ever a situation where you should be putting code like this in page.tpl.php. Maybe with more information someone could suggest an alternative, more "best practice" method for achieving your desired result.
For example: if I want to arbitrarily place form content on some page of my choice, I'd use panels.
And failing that-- if you really can't find a tool like panels that does what you want, then write a custom module to do it. For example:
mymodule.module:
mymodule_menu(){ $items = array();
$item['my/custom/page'] = array( 'title' => t('Title of my page'), 'page callback' => 'drupal_get_form', 'page arguments' => 'user_profile_form', 'access arguments => array('permission the user has to have'), ... ); return $items; }
This code, once the module is enabled and all the cache is cleared, should put the form you want on the path you just named. If you want it in a block, then decalare block content in your module instead of a menu entry, and place the block into a region.
On 09/03/2010 04:16 PM, Kevin Davison wrote:
The following PHP is what I have in a page.tpl.php, and it worked before I upgraded Drupal 6.14 to 6.19 and enabled clean URLs (with Pathauto).
Now when I submit a profile edit, the page just reloads quickly, but nothing is written to the database. Anyone know why? Need more info? Thanks!
<?php global $user; // if the user is logged in if ($user->uid > 0) { module_load_include('inc', 'user', 'user.pages'); profile_load_profile($user); print(drupal_get_form('user_profile_form', $user, 'Personal Information')); } else { // do something else } ?>
OLD CODE...
<?php /* global $user; $uid = $user->uid; if ($uid > 0) { include_once drupal_get_path('module', 'user') . '/user.pages.inc'; // print(drupal_get_form('user_profile_form', $user)); profile_load_profile($user); // var_dump($user); print(drupal_get_form('user_profile_form', $user, 'Personal Information')); } */ ?>
-- [ Drupal support list | http://lists.drupal.org/ ]