1
chefry
Publisher Random Item
  • 2013/2/6 13:30

  • chefry

  • Home away from home

  • Posts: 1005

  • Since: 2006/10/14


The publisher random item block shows the contents of the block summary, if there is one, and the body text.

Can someone tell me how I can also get the Title to appear in the block?

TIA!!!

2
irmtfan
Re: Publisher Random Item
  • 2013/2/6 14:30

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


Quote:

Mamba wrote:
Chefry, try to experiment a little, so you can learn something from it

very true!

just 2 seconds.
open items_random_item.php and add a function
<?php
/*
 You may not change or alter any portion of this comment or credits
 of supporting developers from this source code or any supporting source code
 which is considered copyrighted (c) material of the original comment or credit authors.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */

/**
 * @copyright       The XUUPS Project http://sourceforge.net/projects/xuups/
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
 * @package         Publisher
 * @subpackage      Blocks
 * @since           1.0
 * @author          trabis <lusopoemas@gmail.com>
 * @author          The SmartFactory <www.smartfactory.ca>
 * @version         $Id: items_random_item.php 10374 2012-12-12 23:39:48Z trabis $
 */

defined("XOOPS_ROOT_PATH") or die("XOOPS root path not defined");

include_once 
dirname(dirname(__FILE__)) . '/include/common.php';

function 
publisher_items_random_item_show($options)
{
    
$block = array();
    
$publisher PublisherPublisher::getInstance();
    
// creating the ITEM object
    
$itemsObj $publisher->getHandler('item')->getRandomItem('', array(_PUBLISHER_STATUS_PUBLISHED));

    if (!
is_object($itemsObj)) return $block;

    
$block['content'] = $itemsObj->getBlockSummary(300true); //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;

    return 
$block;
}


then add to template where you prefer
<{$block.content}><br/><br/>

<
div align="right">
    <
a href='<{$block.url}>'><{$block.lang_fullitem}>-><{$block.title}></a>
</
div>


so it is that easy.
It was very easy for you too.


3
chefry
Re: Publisher Random Item
  • 2013/2/6 14:54

  • chefry

  • Home away from home

  • Posts: 1005

  • Since: 2006/10/14


I'm not a programmer so... no, it's not easy for me

that change put the item name in the "read the complete article" link

I wanted the item name ot appear in the block content

4
trabis
Re: Publisher Random Item
  • 2013/2/6 21:08

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:
chefry wrote: I'm not a programmer so... no, it's not easy for me that change put the item name in the "read the complete article" link I wanted the item name ot appear in the block content
You already have the tag <{$block.content}> irmtfan told you how to create the tag <{$block.title}> You are not a programmer nor a designer, but you should know that <{$block.content}> will display the content and that <{$block.title}> will display the title.

5
sabahan
Re: Publisher Random Item
  • 2013/3/31 2:44

  • sabahan

  • Quite a regular

  • Posts: 317

  • Since: 2006/3/4 5


Hi ,

1. how do i publish the image of the random article
2. currently it display 1 random item how do i display 4

6
chefry
Re: Publisher Random Item
  • 2013/3/31 3:36

  • chefry

  • Home away from home

  • Posts: 1005

  • Since: 2006/10/14


You can't publish an image. It's just a simple block. It won't even use any html or bbcodes you have in your article

why would you want to show 4 random articles?

The only thing I can think of is to copy the random article block code and use it to create 3 custom blocks as your random items

7
sabahan
Re: Publisher Random Item
  • 2013/3/31 4:57

  • sabahan

  • Quite a regular

  • Posts: 317

  • Since: 2006/3/4 5


not the image inside of the article but Article featured image that we can upload for every publisher article...


i did this before in my publisher clone module but for Other articles
https://xoops.org/modules/newbb/viewtopic.php?post_id=352477

will try if i can do this for random item



i want to show the 4 random article below article item of each item like blog style

8
sabahan
Re: Publisher Random Item
  • 2013/3/31 5:17

  • sabahan

  • Quite a regular

  • Posts: 317

  • Since: 2006/3/4 5


ok i think got it..add featured image for random article

in items_random_item.php

$mainImage $itemsObj->getMainImage();
        
// check to see if GD function exist
        
if (!function_exists('imagecreatetruecolor')) {
            
$block['item_image'] = $mainImage['image_path'];
        } else {
            
$block['item_image'] = PUBLISHER_URL '/thumb.php?src=' $mainImage['image_path'] . '&amp;w=' $imgwidth// No $imgheight for autoheight option
        
}


template publisher_items_random_item.html



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


at first i got blank page because of this warning
//CAREFUL!! with many items this will exhaust memory
remove $block['lang_fullitem'] = _MB_PUBLISHER_FULLITEM;
notw its ok


now still finding how to show 4 random instead of 1

Quote:

The only thing I can think of is to copy the random article block code and use it to create 3 custom blocks as your random items

another better way ?

9
bjuti
Re: Publisher Random Item
  • 2013/3/31 16:12

  • bjuti

  • Just can't stay away

  • Posts: 871

  • Since: 2009/1/7 2


Nice.. this should be in original version.

Also, it would be nice that every template have title tag in links. It's good for seo.

10
FreddyH
Re: Publisher Random Item
  • 2013/7/16 18:16

  • FreddyH

  • Just popping in

  • Posts: 18

  • Since: 2013/7/1 1


Hmm, I can't get the image to show... where is thumb.php ?

Login

Who's Online

162 user(s) are online (114 user(s) are browsing Support Forums)


Members: 0


Guests: 162


more...

Donat-O-Meter

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

Latest GitHub Commits