I’ll try to explain the situation as clearly as I can.
I’ve got a system in place that presents links to events, created with JEvents for those familiar(in Joomla)
When an event is created in the admin, the category view for it displays a little table, with the event`s date, name, and a link to the event page. All that works fine. Now the link is called on a separate php file than the one that renders the html view for it all.
The link is called with this:
<a class="ev_link_row" href="<?php echo $rowlink; ?>" <?php echo $args;?> style="font-weight:bold;color:<?php echo $fgcolor;?>;" title="<?php echo JEventsHTML::special($row->title()) ;?>"><?php echo $tmpTitle ;?></a>
On the html rendering script, I’ve got this:
$this->viewEventRowNew ( $row,'view_detail',JEV_COM_COMPONENT, $Itemid);
Which is comprised in a for loop above, populating the $row variable with all sorts of info.
for( $r = 0; $r < $num_events; $r++ ){
$row = $data['rows'][$r];
etc.
Now to the question. I’ve got a table that stores imagefile names. I have no trouble creating a forloop that goesthrough the rows and returns the path name to the images, like this:
$db = & JFactory::getDBO();
$query2 = "SELECT `c`.`filename` AS `iname` , `c`.`filetitle` AS `ititle` , `c`.`ev_id` AS `eventid` FROM `#__jev_files` AS `c` ";
$db->setQuery($query2);
$imagelist = $db->loadObjectList();
?>
<?php foreach($imagelist as $row) : ?>
<img src="/images/stories/jevents/<?php echo $row->iname; ?>" />
<?php endforeach; ?>
Now the obvious question, how do I assign this image to be comprised in the link. I tried wrapping the for loop around the linkitself, but it obviously breaks hell as it is reused in a loop(creating a loop within a loop and destroying my layout)
If I use the query in the html-rendering page, then my problem is essentially that I do not know how to append the above to the $row variable without breaking the rest of the functionality.
Thanks, a LOT to anyone who can guide me on this.
I think I could give just the answer you’re looking for if I could understand the question better. Perhaps some of what you’re saying is Joomla-specific so I don’t quite get it.
But generally, object-oriented programming is a good way to keep information about one related thing together, such as all date, description, and collection of images associated with one event. If you can loop through a set of id’s and each ID can be used to create an Event object, then each Event object can be made to retrieve it’s own information and related images. It keeps code like this cleaner.