Adding IF ELSE statement to this line

Need help with your forum? Ask away. Remember though that there's always http://www.phpbb.com/community

Moderator: Experts

Post Reply
Hardcore_Shad
Posts: 15
Joined: Mon Mar 22, 2010 7:06 am

Adding IF ELSE statement to this line

Post by Hardcore_Shad » Sun Mar 28, 2010 10:13 am

Hi all! If I were to add an IF ELSE statement to this code, how could I do it?

I've tried variations to it but could only show the "else" part. :D I intended to place an image or word before the topic title link to show which ones were already "read and unread." So if the topic is new, it shows an image bearing the word "new" before the topic title and vice versa.

Code: Select all

<!-- BEGIN latest_announcements -->
						<a href="{latest_announcements.U_VIEW_TOPIC}" title="{latest_announcements.FULL_TITLE}">{latest_announcements.TITLE}</a><br />
			<!-- END latest_announcements -->
Thanks.

User avatar
DavidIQ
Site Admin
Posts: 581
Joined: Thu Sep 07, 2006 4:31 pm
Location: Earth
Contact:

Re: Adding IF ELSE statement to this line

Post by DavidIQ » Sun Mar 28, 2010 11:50 pm

Something like:

Code: Select all

<!-- BEGIN latest_announcements -->
                  <!-- IF SOMETHING -->this something<!-- ELSE -->something else<!-- ENDIF -->
                  <a href="{latest_announcements.U_VIEW_TOPIC}" title="{latest_announcements.FULL_TITLE}">{latest_announcements.TITLE}</a><br />
<!-- END latest_announcements -->

Hardcore_Shad
Posts: 15
Joined: Mon Mar 22, 2010 7:06 am

Re: Adding IF ELSE statement to this line

Post by Hardcore_Shad » Mon Mar 29, 2010 11:50 am

Thanks David.

I was trying this but only the else statement showed, whether the topic is new or old. Am I formulating my IF statement correctly with S_UNREAD_TOPIC? That's actually the part which I need most help with. :?

Code: Select all

<!-- BEGIN latest_announcements -->
                  <!-- IF S_UNREAD_TOPIC --><a href="{latest_announcements.U_VIEW_TOPIC}" title="{latest_announcements.FULL_TITLE}"> Old !!! {latest_announcements.TITLE}</a><!-- ELSE --><a href="{latest_announcements.U_VIEW_TOPIC}" title="{latest_announcements.FULL_TITLE}"> New !!! {latest_announcements.TITLE}</a><!-- ENDIF -->
<!-- END latest_announcements -->

User avatar
DavidIQ
Site Admin
Posts: 581
Joined: Thu Sep 07, 2006 4:31 pm
Location: Earth
Contact:

Re: Adding IF ELSE statement to this line

Post by DavidIQ » Mon Mar 29, 2010 12:05 pm

It should probably be "latest_announcements.S_UNREAD_TOPIC"

Hardcore_Shad
Posts: 15
Joined: Mon Mar 22, 2010 7:06 am

Re: Adding IF ELSE statement to this line

Post by Hardcore_Shad » Mon Mar 29, 2010 1:01 pm

Woot!

Let me try that out... :D Thanks!


--------------------------


Update: I coded it like this...

Code: Select all

<!-- IF .latest_announcements -->
		<td class="row1" width="33%" valign="top">
			<!-- BEGIN latest_announcements -->
                  <!-- IF latest_announcements.S_UNREAD_TOPIC --><a href="{latest_announcements.U_VIEW_TOPIC}" title="{latest_announcements.FULL_TITLE}"> NEW !!! {latest_announcements.TITLE}</a><!-- ELSE --><a href="{latest_announcements.U_VIEW_TOPIC}" title="{latest_announcements.FULL_TITLE}"> OLD !!! {latest_announcements.TITLE}</a><!-- ENDIF --><br />
<!-- END latest_announcements -->		</td>
		<!-- ENDIF -->
But only the "OLD" option is shown, even if the topics are new. May I have more assistance on how I could code this better pls? :D

Post Reply