Could anyone help re-write this so that it will choose based on gender? In other words, if the user is female, use a different wav and gif. everyone else would use the one in the code.
if($context['user']['unread_messages']>0)
echo '<br />'.$bullet.'<a style="font-weight: bold; " href="', $scripturl, '?action=pm">' .$txt['tp-pm2'].' ',$context['user']['unread_messages'] , ' <img src="' . $settings['images_url'] . '/msg.gif" border="0"><bgsound src="' . $settings['images_url'] . '/Mail01.wav" border="0"></a>';
if(($context['user']['unread_messages']>0) && ($context['member']['gender']['name'] == 'f')
echo '<br />'.$bullet.'<a style="font-weight: bold; " href="', $scripturl, '?action=pm">' .$txt['tp-pm2'].' ',$context['user']['unread_messages'] , ' <img src="' . $settings['images_url'] . '/msg.gif" border="0"><bgsound src="' . $settings['images_url'] . '/Mail01.wav" border="0"></a>';
Try that..
great...that works...but how do i now add a line so that if they are not female then a different message and image is displayed?
Add after that:
elseif(($context['user']['unread_messages']>0) && ($context['member']['gender']['name'] == 'm'))
{
echo '<br />'.$bullet.'<a style="font-weight: bold; " href="', $scripturl, '?action=pm">' .$txt['tp-pm2'].' ',$context['user']['unread_messages'] , ' <img src="' . $settings['images_url'] . '/msg.gif" border="0"><bgsound src="' . $settings['images_url'] . '/Mail01.wav" border="0"></a>';
}
elseif(($context['user']['unread_messages']>0) && ($context['member']['gender']['name'] == ''))
{
echo '<br />'.$bullet.'<a style="font-weight: bold; " href="', $scripturl, '?action=pm">' .$txt['tp-pm2'].' ',$context['user']['unread_messages'] , ' <img src="' . $settings['images_url'] . '/msg.gif" border="0"><bgsound src="' . $settings['images_url'] . '/Mail01.wav" border="0"></a>';
}
It prolly won't work well, because not sure about last elseif. However, I can't think of an easy way to say if unread_message > 0 and member isn't female..
This might do that more easily.
elseif(($context['user']['unread_messages']>0) && (!$context['member']['gender']['name'] == 'f'))
{
echo '<br />'.$bullet.'<a style="font-weight: bold; " href="', $scripturl, '?action=pm">' .$txt['tp-pm2'].' ',$context['user']['unread_messages'] , ' <img src="' . $settings['images_url'] . '/msg.gif" border="0"><bgsound src="' . $settings['images_url'] . '/Mail01.wav" border="0"></a>';
}
Not sure. Maybe.. Haven't tested..
Try the 2nd one first, if it works, should be more efficient..
would it help if i posted the entire block of code?
No, this is the only thing that really matters in it.. Anyway, did u test it?
sorry, yes i did last night....tried several different ways and either it works like it always did or it causes a parse error (it doesn't tell me what was causing the error, just that the line that holds the img and wav tags is the error)
Does the first bit of code work? Or is it only the 2nd one that fails?
surely
if(($context['user']['unread_messages']>0) && ($context['member']['gender']['name'] == 'f')) {
echo for female
}
elseif(($context['user']['unread_messages']>0) && ($context['member']['gender']['name'] == 'f'))
echo for other case
}
demonic... rather than elseif, just use else...
if female
elseif male
else (if anything else - is implied)
dont we still want the ($context['user']['unread_messages']>0)
so
if(($context['user']['unread_messages']>0) && ($context['member']['gender']['name'] == 'f')) {
echo for female
}
elseif($context['user']['unread_messages']>0) {
echo for other case
}
as the original code we are editing was only passed if there are unread messages
either that or nest anouther if statement for the gender query
if($context['user']['unread_messages']>0) {
if($context['member']['gender']['name'] == 'f') {
echo for female
}
else {
echo for other case
}
}
Ya, I was thinking around your lines fwitt.. Just heheh, not as good :)
It ignored the gender call altogether when it did work...otherwise it caused a parse error.
Ughh. CAn't you just say not context gender female with the "!"?
lol..i am getting the feeling that possibly this can't be done :D
Of course it can! Just we need to work on it!
Lainaus käyttäjältä: DemonicInfluence - maaliskuu 29, 2006, 01:09:28 IP
Of course it can! Just we need to work on it!
ALRIGHT!
LOL...If it helps, what I am trying to do is have it check first if the member has any new PM's, then chaeck to see what sex (if defined) they are and then show the flashing image and sound based on the sex (or lack thereof).
So...If they are female it would should a little pink flashing msg icon and play, say, Garth Brooks saying you have mail...if they are male (or no sex defined) then it would show a flashing blue icon, and play some sexy woman saying you have mail.