xoops forums

mjoel

Quite a regular
Posted on: 2/15 15:57
mjoel
mjoel (Show more)
Quite a regular
Posts: 307
Since: 2006/12/9
#1

Adding Main Image in Publisher - Item by same author page

Hi i would like to add main image of article in Publisher item by same author page

here's what i did so far following from some example ... but its not working..i got 500 error page

in publisher/author_items.php...my image code is after the line rating
..i added the bold part
$categories[$catId]['count_items']++;
        
$categories[$catId]['count_hits'] += $item->counter();
        
$categories[$catId]['items'][]    = [
            
'title'     => $item->getTitle(),
            
'hits'      => $item->counter(),
            
'link'      => $item->getItemLink(),
            
'published' => $item->getDatesub(_SHORTDATESTRING),
            
//'rating'    => $xoopsLocal->number_format((float)$item->rating())
            
'rating'    => $item->rating(),
          
'image'     => $item->getMainImage(),
        ];
        
$mainImage       $item->getMainImage();
        
// check to see if GD function exist
        
if (!function_exists('imagecreatetruecolor')) {
            
$item['image'] = $mainImage['image_path'];
        } else {
            
$item['image'] = PUBLISHER_URL '/thumb.php?src=' $mainImage['image_path'] . '&w=' $imgWidth// No $imgHeight for autoheight option
           
}
    }
    
}


in template publisher_author_items.tpl i used

$item.item_image

please help thank you

Mamba

Moderator
Posted on: 2/16 5:26
Mamba
Mamba (Show more)
Moderator
Posts: 10944
Since: 2004/4/23
#2

Re: Adding Main Image in Publisher - Item by same author page

I'm not sure I understand what you would like to do.

Could you provide a screenshot or mockup of what you would like to do, and what do you have currently?
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

mjoel

Quite a regular
Posted on: 2/16 10:31
mjoel
mjoel (Show more)
Quite a regular
Posts: 307
Since: 2006/12/9
#3

Re: Adding Main Image in Publisher - Item by same author page

i'm trying to add main image of the article at the top of every article title in the author page
example of author items page here in xoops.org
Resized Image


not sure what the problem is i tried to paste my image codethat i used in publisher_author_items.tpl but its not appearing correcly in my last post and in this post this is the screenshot of the code
Resized Image

?>

Mamba

Moderator
Posted on: 2/16 18:34
Mamba
Mamba (Show more)
Moderator
Posts: 10944
Since: 2004/4/23
#4

Re: Adding Main Image in Publisher - Item by same author page

Try this in author_items.php:
//mb start
        
$mainImage       $item->getMainImage();
        
$imageThumb $mainImage['image_thumb'];
        
//mb end

        
$categories[$catId]['count_items']++;
        
$categories[$catId]['count_hits'] += $item->counter();
        
$categories[$catId]['items'][]    = [
            
'title'     => $item->getTitle(),
            
'hits'      => $item->counter(),
            
'link'      => $item->getItemLink(),
            
'published' => $item->getDatesub(_SHORTDATESTRING),
            
//'rating'    => $xoopsLocal->number_format((float)$item->rating())
            
'rating'    => $item->rating(),

            
'image'     => $imageThumb,//mb

        
];
Then in the publisher_author_items.tpl you can add this:
<{foreach item=item from=$category.items}>
            <
tr>
                <
td>
                    <{if 
$item.image}>
                        <
img src="<{$item.image}>" alt="<{$item.image_name}>">
                    <{/if}>
                </
td>

                <
td><{$item.published}></td>
                <
td>&nbsp;&nbsp;<{$item.link}></td>
                <
td align='right'><{$item.hits}>  </td>
                <{if 
$permRating}>
                    <
td align='right'>&nbsp;&nbsp;<{$item.rating}></td>
                <{/if}>
            </
tr>
        <{/foreach}>
Of course, you would have to set the template the way you want it to look - the code above was just for testing to see if it works.
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

mjoel

Quite a regular
Posted on: 2/17 4:11
mjoel
mjoel (Show more)
Quite a regular
Posts: 307
Since: 2006/12/9
#5

Re: Adding Main Image in Publisher - Item by same author page

Thank you mamba..code is working fine