Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-24-2006, 11:05 AM
naeemakhtar naeemakhtar is offline
 
Join Date: Jun 2006
Location: London
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default If ...Else...help please!!

Hi there all.

Im new to PHP but having some troube in getting some simple bit of code to work.And I am trying...

I know that the syntax for a PhP if..Else test is basically:

<
if(condition)
dothis....
else
dothat....
>

But inside VBulletin when I go to edit my navbar template I see this:

HTML Code:
<if condition="$bbuserinfo['pmunread']">
<a href="http://www.pakistancricketzone.com/private.php?"><img border="0" src="http://www.pakistancricketzone.com/images/xbox/nonewpm.gif" width="220" height="13"></a>
Thats basically shows a graphic if there is an unread PM.But if there isnt I want it to show a different graphic. So I figured the best thing to do is a if..else statement. No matter what I do it seems to fall over or the else isnt recognised. Can someone tell me why?

HTML Code:
<if condition="$bbuserinfo['pmunread']">
<a href="http://www.pakistancricketzone.com/private.php?"><img border="0" src="http://www.pakistancricketzone.com/images/xbox/nonewpm.gif" width="220" height="13"></a>

		<else>
<a href="http://www.pakistancricketzone.com/private.php?"><img border="0" src="http://www.pakistancricketzone.com/images/xbox/newpm.gif" width="220" height="13"></a>
</if>
As far as i can tell the angle brackets just help to keep selcted bits of code together in a block in php and should be translated into HTML at execution time....still dont know why its not working.Can anyone explain why to me please?

Many thanks,
Naeem

anyone???
Reply With Quote
  #2  
Old 06-24-2006, 02:15 PM
Code Monkey's Avatar
Code Monkey Code Monkey is offline
 
Join Date: May 2004
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<else />
Reply With Quote
  #3  
Old 06-24-2006, 03:56 PM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You might also want to switch your images -- you've got the No New PMs image being displayed when there are Unread Messages and the New PMs Image being displayed when there aren't any.
Reply With Quote
  #4  
Old 06-24-2006, 10:05 PM
naeemakhtar naeemakhtar is offline
 
Join Date: Jun 2006
Location: London
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by acidburn0520
You might also want to switch your images -- you've got the No New PMs image being displayed when there are Unread Messages and the New PMs Image being displayed when there aren't any.
LOL Thanks Guy's. Yep I noticed I did that too and I was gonna go back to edit it but I realised by the time I noticed on the editing what I had done, it would be spotted!!! So well spotted and thanks....

Dont worry it wasnt like that in the actual code as I didnt copy and paste all of it 1st time around. Below is the actual code I put in with <IF><Else/> and its still not working.

Basically if there is a message then show newpm.gif otherwise show nonewpm.gif...at the moment it shows neither or both! For the life of me I really cant see why it shouldnt work....it still 'reads' good to me.:surprised:

HTML Code:
<if condition="$bbuserinfo['pmunread']">
<a href="http://www.....com/private.php?">
<img border="0" src="http://www......com/images/xbox/newpm.gif" width="220" height="13"></a>							<else/>
<a href="http://www.....com/private.php?"><img border="0" src="http://www......com/images/xbox/nonewpm.gif" width="220" height="13"></a>	
</if>
I hope you can spot something in it that I cant...and thanks again for your time and help.
Reply With Quote
  #5  
Old 06-24-2006, 10:13 PM
Code Monkey's Avatar
Code Monkey Code Monkey is offline
 
Join Date: May 2004
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<else /> don't forget the space before the / and it's better if you post your code here in code tags.
Reply With Quote
  #6  
Old 06-24-2006, 10:34 PM
naeemakhtar naeemakhtar is offline
 
Join Date: Jun 2006
Location: London
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by JumpD
<else /> don't forget the space before the / and it's better if you post your code here in code tags.
Yaaaaaaaaaaaaaay!!! Thanks a lot for pointing that out for me!!! It works great now!!!

I always thought that the space before the > didnt matter and that the space was just insignificant! Now i know...many thanks again for your help
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:40 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06291 seconds
  • Memory Usage 2,218KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_html
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete