Subject:*
<
Name/Email:*
<
Message Icon:*
<
Select*
<
Message:*
<



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
5 + 8 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
     
Preferences > System Options > General Settings and set Debug Mode to [i]Enable debug (inline mode)[/i]. 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: [code] /** * @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; } [/code] 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: [code] [/code][/quote]" />

Re: Publisher Random Item Image
by Zap_English on 2017/5/7 8:29:04

That fixed it

YOU DA MAN, BLEEKK!
Re: Publisher Random Item Image
by Bleekk on 2017/5/7 8:19:23

Add this line to the Block function
le="color: #000000"><?php $block['title'] = $itemsObj->title();
Re: Publisher Random Item Image
by Zap_English on 2017/5/7 7:59:21

OK, that worked, HOORAY!

But it caused another problem. Not sure why

The first line of the tpl file I had inserted <center><h4><{$block.title}></h4></center> so that it would display the title of the item.

the next line is your block image, modified as

<img src="<{$block.item_image}>" alt="" width="100" height="100" align="left" style="padding:5px;"/>

So now it displays the image correctly, and the beginning text of the article, but it stopped showing the Title. Now sure why that's happening
Re: Publisher Random Item Image
by Bleekk on 2017/5/6 18:31:28

items_random_item.php change the publisher_items_random_item_show function
le="color: #000000"><?php 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; } $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(); $image = $itemsObj->getMainImage(); $block['image'] = $image['image_path']; if(!$block['image']){ $block['image'] = "path_to_your_default_image"; } $block['lang_fullitem'] = _MB_PUBLISHER_FULLITEM; return $block; }
in template add this
le="color: #000000"><?php <img src="<{$block.image}>"/>
Re: Publisher Random Item Image
by Zap_English on 2017/5/6 17:52:56

Quote:

trabis wrote:
$mainImage = $itemsObj ->getMainImage();

in #2 use this
le="color: #000000"><?php $mainImage = $itemsObj - >getMainImage(); if(!$mainImage['image_path'] ){ $mainImage['image_path']='urltoyourdefaultimage'; }

Not tested, sent by phone.

Who's Online

169 user(s) are online (143 user(s) are browsing Support Forums)


Members: 0


Guests: 169


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits