I'm using Drupal five, building a theme off of Zen. I want to optionally display a user's picture in posts, so that if the user has uploaded a picture then it is displayed, and if not then the teaser view shifts left to occupy that space.
So I turned on pictures in the theme configuration. But now, where there is no picture available, I have a "soandso's picture" link.
Specifically: I want if( $picture ){...} in the .tpl.php file to evaluate to FALSE if there is no picture, TRUE if there is one. How can I get this behavior? Is there a theme override that I'm missing?
You didn't mention turning on Picture Support in user settings. To do so go to Adminster | User management | User settings (/admin/user/settings) and scroll down to the "Picture support" section. This is where you select you default picture, as well.
On Mon, Dec 1, 2008 at 10:13 AM, Christopher M. Jones cjones@partialflow.com wrote:
I'm using Drupal five, building a theme off of Zen. I want to optionally display a user's picture in posts, so that if the user has uploaded a picture then it is displayed, and if not then the teaser view shifts left to occupy that space.
So I turned on pictures in the theme configuration. But now, where there is no picture available, I have a "soandso's picture" link.
Specifically: I want if( $picture ){...} in the .tpl.php file to evaluate to FALSE if there is no picture, TRUE if there is one. How can I get this behavior? Is there a theme override that I'm missing?
-- [ Drupal support list | http://lists.drupal.org/ ]
Thanks, yes. I assumed that step. To clarify: I have pictures enabled and they show in my templates. But where no picture exists, because the user has not uploaded one, I have a link that reads "username's picture". I not only want to remove that link but I want to adjust the layout to compensate for the lack of a picture.
Dale McGladdery wrote:
You didn't mention turning on Picture Support in user settings. To do so go to Adminster | User management | User settings (/admin/user/settings) and scroll down to the "Picture support" section. This is where you select you default picture, as well.
On Mon, Dec 1, 2008 at 10:13 AM, Christopher M. Jones cjones@partialflow.com wrote:
I'm using Drupal five, building a theme off of Zen. I want to optionally display a user's picture in posts, so that if the user has uploaded a picture then it is displayed, and if not then the teaser view shifts left to occupy that space.
So I turned on pictures in the theme configuration. But now, where there is no picture available, I have a "soandso's picture" link.
Specifically: I want if( $picture ){...} in the .tpl.php file to evaluate to FALSE if there is no picture, TRUE if there is one. How can I get this behavior? Is there a theme override that I'm missing?
-- [ Drupal support list | http://lists.drupal.org/ ]
I know this might seem like a silly question but can you just confirm that text shows up in both FF and IE.
----- Original Message ----- From: "Christopher M. Jones" cjones@partialflow.com To: support@drupal.org Sent: Tuesday, December 02, 2008 10:23 PM Subject: Re: [support] getting rid of "soandso's picture" text
Thanks, yes. I assumed that step. To clarify: I have pictures enabled and they show in my templates. But where no picture exists, because the user has not uploaded one, I have a link that reads "username's picture". I not only want to remove that link but I want to adjust the layout to compensate for the lack of a picture.
Dale McGladdery wrote:
You didn't mention turning on Picture Support in user settings. To do so go to Adminster | User management | User settings (/admin/user/settings) and scroll down to the "Picture support" section. This is where you select you default picture, as well.
On Mon, Dec 1, 2008 at 10:13 AM, Christopher M. Jones cjones@partialflow.com wrote:
I'm using Drupal five, building a theme off of Zen. I want to optionally display a user's picture in posts, so that if the user has uploaded a picture then it is displayed, and if not then the teaser view shifts left to occupy that space.
So I turned on pictures in the theme configuration. But now, where there is no picture available, I have a "soandso's picture" link.
Specifically: I want if( $picture ){...} in the .tpl.php file to evaluate to FALSE if there is no picture, TRUE if there is one. How can I get this behavior? Is there a theme override that I'm missing?
-- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
The variable in node.tpl.php that stores the user picture is (aptly named) $picture. In the template file, just put a conditional statement that uses $picture only if it contains something:
<?php if ($picture): ?> <div id='user_picture'> <?php print $picture; ?> </div> <!--end picture div--> <?php endif; ?>
That way. the user_picture div only exists if there is actually a picture. This is the way that regions are commonly laid out in a page so that they don't show up if they don't contain any content.
Steve
Christopher M. Jones wrote:
Thanks, yes. I assumed that step. To clarify: I have pictures enabled and they show in my templates. But where no picture exists, because the user has not uploaded one, I have a link that reads "username's picture". I not only want to remove that link but I want to adjust the layout to compensate for the lack of a picture.
Dale McGladdery wrote:
You didn't mention turning on Picture Support in user settings. To do so go to Adminster | User management | User settings (/admin/user/settings) and scroll down to the "Picture support" section. This is where you select you default picture, as well.
On Mon, Dec 1, 2008 at 10:13 AM, Christopher M. Jones cjones@partialflow.com wrote:
I'm using Drupal five, building a theme off of Zen. I want to optionally display a user's picture in posts, so that if the user has uploaded a picture then it is displayed, and if not then the teaser view shifts left to occupy that space.
So I turned on pictures in the theme configuration. But now, where there is no picture available, I have a "soandso's picture" link.
Specifically: I want if( $picture ){...} in the .tpl.php file to evaluate to FALSE if there is no picture, TRUE if there is one. How can I get this behavior? Is there a theme override that I'm missing?
-- [ Drupal support list | http://lists.drupal.org/ ]
Take a look at theme_user_picture (http://api.drupal.org/api/function/theme_user_picture/5).
Overriding it may be your answer. Changing it will change the way the user picture is output everywhere on your site, it may not be exactly what you need.
Another potential strategy is doing something like as follows (warning, I haven't thought this completely through and I haven't used Zen): In the Zen template preprocessor function, put in something like this: global $user: if ($user->picture) { $vars['width-css-class'] = 'has-picture'; } else { $vars['width-css-class'] = 'no-picture'; $vars['picture'] = ''; // This is example and might not be the correct value for the picture }
The in your template.php you can do something like: <?php if ($picture): ?> <div class="picture"><?php print $picture ?></div> <?php endif; ?> <div class="<?php print $width-css-class ?>"> The content stuff </div>
On Tue, Dec 2, 2008 at 1:23 PM, Christopher M. Jones cjones@partialflow.com wrote:
Thanks, yes. I assumed that step. To clarify: I have pictures enabled and they show in my templates. But where no picture exists, because the user has not uploaded one, I have a link that reads "username's picture". I not only want to remove that link but I want to adjust the layout to compensate for the lack of a picture.
Dale McGladdery wrote:
You didn't mention turning on Picture Support in user settings. To do so go to Adminster | User management | User settings (/admin/user/settings) and scroll down to the "Picture support" section. This is where you select you default picture, as well.
On Mon, Dec 1, 2008 at 10:13 AM, Christopher M. Jones cjones@partialflow.com wrote:
I'm using Drupal five, building a theme off of Zen. I want to optionally display a user's picture in posts, so that if the user has uploaded a picture then it is displayed, and if not then the teaser view shifts left to occupy that space.
So I turned on pictures in the theme configuration. But now, where there is no picture available, I have a "soandso's picture" link.
Specifically: I want if( $picture ){...} in the .tpl.php file to evaluate to FALSE if there is no picture, TRUE if there is one. How can I get this behavior? Is there a theme override that I'm missing?
-- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
Thanks, all. I forgot that I had set a default picture, which no longer exists in the original location. Where I was getting the "username's picture' it was because of an empty <img> tag. FF just displayed the link, but I finally saw in IE the broken img icon. So I was right the first time: I test on $picture, and it works when there -really- isn't a picture.
Sorry to waste your time.
Dale McGladdery wrote:
Take a look at theme_user_picture (http://api.drupal.org/api/function/theme_user_picture/5).
Overriding it may be your answer. Changing it will change the way the user picture is output everywhere on your site, it may not be exactly what you need.
Another potential strategy is doing something like as follows (warning, I haven't thought this completely through and I haven't used Zen): In the Zen template preprocessor function, put in something like this: global $user: if ($user->picture) { $vars['width-css-class'] = 'has-picture'; } else { $vars['width-css-class'] = 'no-picture'; $vars['picture'] = ''; // This is example and might not be the correct value for the picture }
The in your template.php you can do something like:
<?php if ($picture): ?>
<div class="picture"><?php print $picture ?></div> <?php endif; ?> <div class="<?php print $width-css-class ?>"> The content stuff </div>
On Tue, Dec 2, 2008 at 1:23 PM, Christopher M. Jones cjones@partialflow.com wrote:
Thanks, yes. I assumed that step. To clarify: I have pictures enabled and they show in my templates. But where no picture exists, because the user has not uploaded one, I have a link that reads "username's picture". I not only want to remove that link but I want to adjust the layout to compensate for the lack of a picture.
Dale McGladdery wrote:
You didn't mention turning on Picture Support in user settings. To do so go to Adminster | User management | User settings (/admin/user/settings) and scroll down to the "Picture support" section. This is where you select you default picture, as well.
On Mon, Dec 1, 2008 at 10:13 AM, Christopher M. Jones cjones@partialflow.com wrote:
I'm using Drupal five, building a theme off of Zen. I want to optionally display a user's picture in posts, so that if the user has uploaded a picture then it is displayed, and if not then the teaser view shifts left to occupy that space.
So I turned on pictures in the theme configuration. But now, where there is no picture available, I have a "soandso's picture" link.
Specifically: I want if( $picture ){...} in the .tpl.php file to evaluate to FALSE if there is no picture, TRUE if there is one. How can I get this behavior? Is there a theme override that I'm missing?
-- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
Ah OK, that's where I was going (slowly!) with my "is it FF or IE?" question. :-)
same thing happened to me a year back.
Neil
----- Original Message ----- From: "Christopher M. Jones" cjones@partialflow.com To: support@drupal.org Sent: Tuesday, December 02, 2008 11:10 PM Subject: Re: [support] [SOLVED] getting rid of "soandso's picture" text
Thanks, all. I forgot that I had set a default picture, which no longer exists in the original location. Where I was getting the "username's picture' it was because of an empty <img> tag. FF just displayed the link, but I finally saw in IE the broken img icon. So I was right the first time: I test on $picture, and it works when there -really- isn't a picture.
Sorry to waste your time.
Dale McGladdery wrote:
Take a look at theme_user_picture (http://api.drupal.org/api/function/theme_user_picture/5).
Overriding it may be your answer. Changing it will change the way the user picture is output everywhere on your site, it may not be exactly what you need.
Another potential strategy is doing something like as follows (warning, I haven't thought this completely through and I haven't used Zen): In the Zen template preprocessor function, put in something like this: global $user: if ($user->picture) { $vars['width-css-class'] = 'has-picture'; } else { $vars['width-css-class'] = 'no-picture'; $vars['picture'] = ''; // This is example and might not be the correct value for the picture }
The in your template.php you can do something like:
<?php if ($picture): ?>
<div class="picture"><?php print $picture ?></div> <?php endif; ?> <div class="<?php print $width-css-class ?>"> The content stuff </div>
On Tue, Dec 2, 2008 at 1:23 PM, Christopher M. Jones cjones@partialflow.com wrote:
Thanks, yes. I assumed that step. To clarify: I have pictures enabled and they show in my templates. But where no picture exists, because the user has not uploaded one, I have a link that reads "username's picture". I not only want to remove that link but I want to adjust the layout to compensate for the lack of a picture.
Dale McGladdery wrote:
You didn't mention turning on Picture Support in user settings. To do so go to Adminster | User management | User settings (/admin/user/settings) and scroll down to the "Picture support" section. This is where you select you default picture, as well.
On Mon, Dec 1, 2008 at 10:13 AM, Christopher M. Jones cjones@partialflow.com wrote:
I'm using Drupal five, building a theme off of Zen. I want to optionally display a user's picture in posts, so that if the user has uploaded a picture then it is displayed, and if not then the teaser view shifts left to occupy that space.
So I turned on pictures in the theme configuration. But now, where there is no picture available, I have a "soandso's picture" link.
Specifically: I want if( $picture ){...} in the .tpl.php file to evaluate to FALSE if there is no picture, TRUE if there is one. How can I get this behavior? Is there a theme override that I'm missing?
-- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]