1
mjoel
Adding Main Image in Publisher - Item by same author page
  • 2020/2/15 15:57

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


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

2
Mamba
Re: Adding Main Image in Publisher - Item by same author page
  • 2020/2/16 5:26

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


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

3
mjoel
Re: Adding Main Image in Publisher - Item by same author page
  • 2020/2/16 10:31

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


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

?>

4
Mamba
Re: Adding Main Image in Publisher - Item by same author page
  • 2020/2/16 18:34

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


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

5
mjoel
Re: Adding Main Image in Publisher - Item by same author page
  • 2020/2/17 4:11

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


Thank you mamba..code is working fine

Login

Who's Online

198 user(s) are online (131 user(s) are browsing Support Forums)


Members: 0


Guests: 198


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