Add thumbnail pics to the upcoming events module

  • ebemoore
  • Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 6 months ago #20286 by ebemoore
Hello,

Could you please tell me how to add a thumbnail pic to be displayed in the "upcoming events" module? Thank you so much for your help.

Ester

Please Log in or Create an account to join the conversation.

More
11 years 6 months ago - 11 years 6 months ago #20507 by gabree
Hi, I have this wish as well.

I've read that the 1.4.5 version has the thumbnail feature,
but since I could not download it, and I have the 1.4 version, I have made this way.

I needed to put an image separated from the short description:

1) I modified the events and put an image in each event, in the short description, and save the events.
2) modify the code of the view template (ie location view, but could also be done in the upcoming events module)
my_site/components/com_eventbooking/views/location/tmpl/default.php

3) put the code to show the image where I wanted:
Code:
<?php //store short description $str = $item->short_description; //reg expression to match image preg_match_all ('/<img[^>]+src\s*=\s*(["\'])?([^>\s]+)\1[^>]*>/i' , $str , $matches ); //set images to null $event_img = null; if (is_array($matches) && !empty($matches)) { $event_img = $matches[2][0]; } //check if image exist if (($event_img != null) && (strlen($event_img)>0)) { $image_name = $event_img; } else { //if image does not exist, put a placeholder $image_name = "/images/img_default.jpg"; } //display image (or placeholder) ?> <p><a href="<?php echo $url; ?>"><img src="<?php echo $image_name; ?>" alt="" /></a></p>


4) Optional, in the location or category template, search for the lines where "<?php echo $item->short_description ; ?>" is,
and replace with this code, in order to not repeat the image twice.
Code:
<?php //strip tags (except paragraph, anchor, etc.) from short description so that image does not show up $new_str = strip_tags($item->short_description, '<p><a><br><div><strong><em>'); //display short description limiting to 110 characters echo $new_str; endif; ?>

5) At last, resized the image with css, in order to make it appear as a thumbnail.

don't know if this could be useful to you,
I attach the image of the upcoming events module, with the title and the image thumbnail.

Attachments:
Last edit: 11 years 6 months ago by gabree. Reason: wrong answer

Please Log in or Create an account to join the conversation.

More
11 years 6 months ago #20684 by gabree
I've posted the solution for a previous release,
now I'm posting the solution for 1.5 version.

1) open the main module file:
modules/mod_eb_events/mod_eb_events.php

on line 34 modify the query adding the thumb, this way:
change from this
Code:
$sql = 'SELECT a.id, a.title, a.location_id, a.event_date, c.name AS location_name FROM #__eb_events AS a '

to this
Code:
$sql = 'SELECT a.id, a.title, a.location_id, a.event_date, a.thumb, c.name AS location_name FROM #__eb_events AS a '

save and close the file.

2) open the template file:
modules/mod_eb_events/tmpl/default.php

put the thumbnail code anywhere you like it
Code:
<?php if ($row->thumb && file_exists(JPATH_ROOT.'/media/com_eventbooking/images/thumbs/'.$row->thumb)) { ?> <a href="<?php echo JRoute::_('index.php?option=com_eventbooking&task=view_event&event_id='.$row->id); ?>&Itemid=<?php echo $itemId; ?>"><img src="<?php echo JURI::base().'media/com_eventbooking/images/thumbs/'.$row->thumb; ?>" /></a> <?php } ?>

that's all, attached is an example.

Attachments:

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc