hi,i'm new to drupal 6.x.

these days i wanted to custom user login page and followed here some instructions ,succeed.
but when i logined, i don't use customed page for links "My count" path....
i mean:i want anonymous user visiting http://192.168.2.10/drupal/user links (login page) with a template file ,but login user visit http://192.168.2.10/drupal/user links (profile page ) with a different template file,how to do this?
hope anyone can tell me?

i did add below code to my template.php file, and touch page-user-login.tpl.php page-user-register.tpl.php page-user-password.tpl.php 3 files!
function phptemplate_preprocess_page(&$vars) {

if (module_exists('path')) {
$alias = drupal_get_path_alias(str_replace('/edit','',$_GET['q']));
if ($alias != $_GET['q']) {
$suggestions = array();
$template_filename = 'page';

foreach (explode('/', $alias) as $path_part) {

$template_filename = $template_filename . '-' . $path_part;
$suggestions[] = $template_filename;

}

}
$vars['template_files'] = $suggestions;
}
}

Comments

linora’s picture

hope you reply....

jefkin’s picture

I'm fairly new to drupal six theming as well, but It looks like you've got the basics there.

A) I suggest you check out http://groups.drupal.org/drupal-dojo there are some D6 theming videos there that are just amazingly helpful.

B) instead of a reliance on paths (which isn't too painful, since path's is almost always installed but I digress), I think you could use the following:

function phptemplate_preprocess_page(&$vars)
{
  $part = 0;
  $sug  = '';
  $sugs = array ( );

  while ($piece = arg($part))
  {
    $sug   .= (($sug) ? '-' : '') . $piece;
    $sugs[] = $sug;
    ++$part;
  }
  $vars['template_files'] = $sugs;
}

Though you might want to start it with some defaults like this:

function phptemplate_preprocess_page(&$vars)
{
  $part = 1;
  $sug  = 'user-special-';
  $sugs = array ( 'user-special', );

  while ($piece = arg($part))
  {
    $sug   .= '-' . $piece;
    $sugs[] = $sug;
    ++$part;
  }
  $vars['template_files'] = $sugs;
}

Either way, imo you can get at the url components easier with the arg() function.

Anonymous’s picture

This page was helpful when I was attempting something similar:

http://drupal.org/node/350634

It's not *exactly* the same, but it might give you some ideas for an easier way to do what you want to do.

Happy day,
Anne