Drupal 6: drupal_render gives "blank" results

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by jessSchn on April 24, 2012 at 1:19pm

Hi,

I'm trying to add an image to the login page of my drupal 6 site. I've gone into the template.php file and added the following lines of code:

function helpsys_theme(&$existing, $type, $theme, $path) {
$hooks = zen_theme($existing, $type, $theme, $path);

$hooks['user_login'] = array(
'template' => 'user-login',
'arguments' => array('form' => NULL)
);

return $hooks;
}

function helpsys_preprocess_user_login(&$variables) {
$variables['rendered'] = drupal_render($variables['form']);
}

I then created a user-login.tpl.php page and added the following lines of code:

<div class="my-form-wrapper">
<?php print $rendered; ?>
</div>
<img style="float:right" src="sites/all/themes/helpsys/images/SS_SitePromo.png" alt="Solutions Summit Promotion" />

I then flush all the caches and when I view my login page, I get the "User Account" title and the image is displaying but the login form is not displaying.

I have looked over my code again and again and I cannot figure out why my login form isn't displaying. Any help would be appreciated.

AttachmentSize
Screen Shot 2012年04月24日 at 8.18.10 AM.png 51.77 KB
Categories: ,

Comments

Jess,
While I do have pretty good PHP knowledge and skills, I do not have hardly any knowledge of Drupal conventions and how Drupal does things in code based on its own conventions (what it does automatically with certain functions). I most often (almost always) just use the browser admin interface. So, I add a block, put whatever in a block and then set the block to appear only on certain pages (instead of a block, panels or mini-panels can be used). There also may well be a way to put the image tag in the right part of some existing page template that may simply, with that, make the image be on the log-in page. PHP pages are happy to just have some html mixed in which gets sent on as is.

While I may have many years of doing PHP, I really have only about 6 months experience with drupal. You are kind of asking the wrong guy and should likely address the question to the whole group.

Just looking at the PHP you provide (but not being at all sure what Drupal automatically looks for and does with things):
* I do not know when your/the function, helpsys_theme , is called
or what receives the array (you add an element to) returned
by that function.
* 'rendered' looks like the name (index) of an element in the
$variables associative array and not a simple variable unto itself.
On the surface it seems to have
no relationship to the $rendered variable you use in
print $rendered -- unless Drupal automatically just assigns such
an array element to such a variable with the processing of
$variables['rendered'] it does.
* I assume helpsys_preprocess_user_login is automatically called
by Drupal but it doesn't look like you have set-up anything that
would effect the value of $variables['form'] (unless you have
succeeded in making something NULL !?? -- and it is hard to
imagine how that would help anything)

In a way this is a very stupid response, but it is all I have.

seems to be the hard way

Posted by maryannking on April 24, 2012 at 2:31pm

Jessie,

Have you used firebug to make sure the login form is there

I am not a php person, so I know that sometimes there is an easier solution. And the fact that it is a form -- how does your image affect it - is it part of it or does it push it out of the way, etc.

I know I have done things such as login toboggan and given it a whole different look with just adding css to it.

I'm also thinking that maybe you could have added that to the page with context and some css?

just some ideas ...

maryann

Maybe

Posted by mark_anthony on April 24, 2012 at 11:09pm

Once you get the form issue figured, the better way to add an image to a page is to do with through css. You should not have to alter any php or tpl files.

I have used the Themer module to give tags classes. Then use css to put a background image in.

Is your site local on your own machine or up online?

-ma

Twin Cities

Group events

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /