15
@Zap_English,
Unfortunately it's a little more complex than just adding anything that's been previously posted in this thread. The random item block does not currently display the main item image, just the item itself.
Let me state: I have not tried any of the following code, I don't have the module currently loaded on my test site and I'm sorry but I don't have time right now to go try/test this. So anything you see/use below is "at your own risk"... Before you try this code I'd recommend you go to your XOOPS Admin > Preferences > System Options > General Settings and set Debug Mode to
Enable debug (inline mode).
Basically what needs to happen is that in ./blocks/items_random_item.php you will need to get the item's main image thumbnail, if it doesn't exist then substitute you're default image. Then in the ./templates/blocks/publisher_items_random_item.tpl you will need to display the image.
The publisher_items_random_item_show() function in ./blocks/items_random_item.php should look something like:
/**
* @param $options
*
* @return array
*/
function publisher_items_random_item_show($options)
{
$block = array();
$publisher = PublisherPublisher::getInstance();
// creating the ITEM object
$itemsObj = $publisher->getHandler('item')->getRandomItem('', array(PublisherConstants::PUBLISHER_STATUS_PUBLISHED));
if (!is_object($itemsObj)) {
return $block;
}
$mainImage = $itemsObj->getMainImage();
if (empty($mainImage['image_thumb'])) {
// the in the following line path_to_your_default_image_thumbnail should be something
// like XOOPS_UPLOADS_URL . "publisher/default_thumbnail.jpg"
$mainImage['image_thumb'] = {path_to_your_default_image_thumbnail};
}
$block['content'] = $itemsObj->getBlockSummary(300, true); //show complete summary but truncate to 300 if only body available
$block['id'] = $itemsObj->itemid();
$block['url'] = $itemsObj->getItemUrl();
$block['title'] = $itemsObj->title(); // irmtfan
$block['lang_fullitem'] = _MB_PUBLISHER_FULLITEM;
$block['item_thumb'] = $mainImage['item_thumb'];
return $block;
}
Now, provided you're using the standard templates (i.e. they haven't been modified) you should be able to use the following in your ./templates/blocks/publisher_items_random_item.tpl file:
<{$block.content}><br><br>
<br class="clear">
<div class="floatleft">
<img class="pad3" src="<{$block.item_thumb}>" alt="" title="<{$block['title']}>">
div>
<div align="right">
<a href='<{$block.url}>'><{$block.lang_fullitem}>a>
div>