xoops forums

chefry

Home away from home
Posted on: 2013/2/6 8:30
chefry
chefry (Show more)
Home away from home
Posts: 1005
Since: 2006/10/14
#1

Publisher Random Item

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!!!

irmtfan

Module Developer
Posted on: 2013/2/6 9:30
irmtfan
irmtfan (Show more)
Module Developer
Posts: 3419
Since: 2003/12/7
#2

Re: Publisher Random Item

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& ...  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.

chefry

Home away from home
Posted on: 2013/2/6 9:54
chefry
chefry (Show more)
Home away from home
Posts: 1005
Since: 2006/10/14
#3

Re: Publisher Random Item

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

trabis

Core Developer
Posted on: 2013/2/6 16:08
trabis
trabis (Show more)
Core Developer
Posts: 2267
Since: 2006/9/1 1
#4

Re: Publisher Random Item

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.

sabahan

Quite a regular
Posted on: 2013/3/30 22:44
sabahan
sabahan (Show more)
Quite a regular
Posts: 315
Since: 2006/3/4 0
#5

Re: Publisher Random Item

Hi ,

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

chefry

Home away from home
Posted on: 2013/3/30 23:36
chefry
chefry (Show more)
Home away from home
Posts: 1005
Since: 2006/10/14
#6

Re: Publisher Random Item

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

sabahan

Quite a regular
Posted on: 2013/3/31 0:57
sabahan
sabahan (Show more)
Quite a regular
Posts: 315
Since: 2006/3/4 0
#7

Re: Publisher Random Item

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
http://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

sabahan

Quite a regular
Posted on: 2013/3/31 1:17
sabahan
sabahan (Show more)
Quite a regular
Posts: 315
Since: 2006/3/4 0
#8

Re: Publisher Random Item

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 ?

bjuti

Just can't stay away
Posted on: 2013/3/31 12:12
bjuti
bjuti (Show more)
Just can't stay away
Posts: 871
Since: 2009/1/7 1
#9

Re: Publisher Random Item

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.

FreddyH

Just popping in
Posted on: 2013/7/16 14:16
FreddyH
FreddyH (Show more)
Just popping in
Posts: 18
Since: 2013/7/1 1
#10

Re: Publisher Random Item

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