A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Simple? php script?

  1. #1
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930

    Simple? php script?

    Alright...I'm an AS3 programmer and am switching to php and have some issues.

    I've got a Joomla site and I need to display graphics (either a gray or color version) based on the title of the "tag" that is being used for that particular Joomla article. I've sort of got it working, but it's not the most efficient code and it's not working completely correctly (displays multiple versions of the images).

    Instead of just continuing to try options and bang my head, I thought I'd throw it out there to see if any of you php gurus can see something obviously easier and more efficient.

    Here's the code (finds the tags and displays the right image, but it's ugly and, displays multiple versions of the graphic...I'm sure it's because the break is placed wrong, so I'm fixing that now (the second group is coded slightly different than the second one, just trying other options...there are 6 of these sections/images total):

    Code:
    						<td>
    							<?php $tmp="0" ?>
    							<?php foreach ($this->item->tags as $tag): ?>
    								<?php if ($tag->name == "Thinking"): ?>
    									<?php $tmp="1"; ?>
    									<?php break; ?>
    								<?php endif; ?>
    								<?php if ($tmp=="1"): ?>
    									<img src="templates/images/1-Thinking-color.gif" width="111" height="40" />
    								<?php else: ?>
    									<img src="templates/images/1-Thinking-gray.gif" width="111" height="40" />
    								<?php endif; ?>
    							<?php endforeach; ?>
    							 </td>
    						<td>
    							<?php foreach ($this->item->tags as $tag): ?>
    								<?php if ($tag->name == "Focus"): ?>
    									<img src="templates/images/2-Focus-color.gif" width="111" height="40" />
    									<?php break; ?>
    								<?php else: ?>
    									<img src="templates/images/2-Focus-gray.gif" width="111" height="40" />
    								<?php endif; ?>
    							<?php endforeach; ?>
    						</td>
    Thanks!
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

  2. #2
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930
    Got it...just had my <?php endforeach; ?> in the wrong spot. Works great now...if anyone has a more efficient way to do this for 6 images I'd appreciate the insight. Maybe making an array of the tags and changing the image names so they match the tag name and then throwing -color or -gray after...would still need a foreach and if at each graphic though...
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center