5 Replies - 4190 Views - Last Post: 10 March 2011 - 09:29 AM Rate Topic: -----

#1 dbeaird727  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 238
  • Joined: 13-December 10

Styling PHP Variable?

Posted 10 March 2011 - 08:30 AM

Is there a way to style a PHP variable? I have a link to a users inbox and pending friend requests on my site and I have the variable: $unreadCount. When this is active I want It to be red so that it sticks out when someone has a message. Any Ideas?

			<div style="border-bottom: 1px solid #ecebeb; margin: 4px 0; padding: 0 0 10px;">				
				<div style="background: transparent url(<?php echo JURI::root(); ?>modules/mod_hellome/images/icons-16x16.gif) no-repeat 0 -118px; padding: 0 0 0 22px;">
					<a style="color:#9b1812; line-height: 18px;" href="<?php echo CRoute::_('index.php?option=com_community&view=inbox'); ?>"><?php echo JText::sprintf( (cIsPlural($unreadCount)) ? 'MOD_HELLOME NEW MESSAGE MANY' : 'MOD_HELLOME NEW MESSAGE', $unreadCount); ?></a>
				</div>
				<div style="background: transparent url(<?php echo JURI::root(); ?>modules/mod_hellome/images/icons-16x16.gif) no-repeat 0 -180px; padding: 0 0 0 22px;">
					<a style="line-height: 18px;" href="<?php echo CRoute::_('index.php?option=com_community&view=friends&task=pending'); ?>"><?php echo JText::sprintf( (cIsPlural($pending)) ? 'MOD_HELLOME NEW FRIEND REQUEST MANY' : 'MOD_HELLOME NEW FRIEND REQUEST', $pending); ?></a>
				</div>
			</div>



Is This A Good Question/Topic? 0
  • +

Replies To: Styling PHP Variable?

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3554
  • View blog
  • Posts: 10,332
  • Joined: 08-June 10

Re: Styling PHP Variable?

Posted 10 March 2011 - 08:40 AM

a PHP variable never has a visual style, as PHP is a programming language, not a markup language.

what you certainly mean is the style of an HTML element having the text of the variable’s content, which is a matter of CSS.
Was This Post Helpful? 0
  • +
  • -

#3 dbeaird727  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 238
  • Joined: 13-December 10

Re: Styling PHP Variable?

Posted 10 March 2011 - 08:41 AM

How would I style this particular element to show red when there is something in the "$unreadCount"?
Was This Post Helpful? 0
  • +
  • -

#4 VolcomMky  Icon User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

Re: Styling PHP Variable?

Posted 10 March 2011 - 08:59 AM

if($unreadCount > 0)
{
   $unreadCount = '<font color="red">'.$unreadCount.'</font>';
}
else
{
   $unreadCount = '<font color="green">'.$unreadCount.'</font>';
}


Something like that.
Was This Post Helpful? 0
  • +
  • -

#5 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3554
  • View blog
  • Posts: 10,332
  • Joined: 08-June 10

Re: Styling PHP Variable?

Posted 10 March 2011 - 09:07 AM

fo the sake of proper HTML, let’s use
# given that you have defined the classes in your CSS
if($unreadCount > 0)
{
   $unreadCount = '<a class="red">'.$unreadCount.'</a>';
}
else
{
   $unreadCount = '<a class="green">'.$unreadCount.'</a>';
}

Was This Post Helpful? 0
  • +
  • -

#6 VolcomMky  Icon User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

Re: Styling PHP Variable?

Posted 10 March 2011 - 09:29 AM

I was debating using classes, but didn't want to be asked how or where to create the CSS Classes
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1