xoops forums

heyula

Theme Designer
Posted on: 2019/6/19 16:36
heyula
heyula (Show more)
Theme Designer
Posts: 486
Since: 2008/4/24
#1

Publisher SliderProblem

Working on older versions of the publisher

<{php}>
include_once 
XOOPS_ROOT_PATH '/modules/publisher/include/common.php';
$publisher =& PublisherPublisher::getInstance();
$myts =& MyTextSanitizer::getInstance();
$itemsObj $publisher->getHandler('item')->getItems($limit 10$start 0, array(_PUBLISHER_STATUS_PUBLISHED), -1$sort 'datesub'$order='DESC'''true$criteria nulltrue);
$totalItems count($itemsObj);

global 
$items;
$items = array();
if (
$itemsObj) {
        for ( 
$i 0$i $totalItems$i++ ) {

            
$newItems['itemid']       = $itemsObj[$i]->itemid();
            
$newItems['title']        = $itemsObj[$i]->title();
            
$newItems['body']         = $itemsObj[$i]->body();
            
$newItems['votes']        = $itemsObj[$i]->votes();
            
$newItems['image']        = XOOPS_URL '/uploads/blank.gif';
            
$images $itemsObj[$i]->getImages();
            if (
is_object($images['main'])) {
                
$newItems['image'] = XOOPS_URL '/uploads/' $images['main']->getVar('image_name');
            }
        
$items[] = $newItems;
    }
}
<{/
php}>
<!-- 
Slider -->
    <
div id="slider">
        <
a href="#" id="prev" class="notext"></a>
        <
a href="#" id="next" class="notext"></a>
        
        <
div id="slider-content">
            <
ul>
            <{
php}>
        foreach ( 
$GLOBALS['items'] as $myrow )
        {
        
$GLOBALS['xoopsTpl']->assign('itemid'$myrow['itemid']);
        
$GLOBALS['xoopsTpl']->assign('title'$myrow['title']);
        
$GLOBALS['xoopsTpl']->assign('body'$myrow['body']);
        
$GLOBALS['xoopsTpl']->assign('votes'$myrow['votes']);
        
$GLOBALS['xoopsTpl']->assign('image'$myrow['image']);
<{/
php}>
                <
li>
                    <
div class="left-side">
                        <
a href="<{$xoops_url}>/modules/publisher/item.php?itemid=<{$itemid}>"><img src="<{$image}>" alt="<{$title}>" width="400px" height="200px"/></a>
                    </
div>
                    
                    <
div class="right-side" >
                        <
h1><a  href="<{$xoops_url}>/modules/publisher/item.php?itemid=<{$itemid}>" title="<{$title}>"><{$title}></h1>
                        <
p><{$body|truncate:220}></p>
                        
                        <
class="readmore"><a style="color:#ff0000" href="<{$xoops_url}>/modules/publisher/item.php?itemid=<{$itemid}>">ÊÊãÉ &raquo;</a></p>
                    </
div>
                    
                    <
div class="cl">&nbsp;</div>
                </
li>
                <{
php}>
        }
<{/
php}> 
            </
ul>
        </
div>
    </
div>
    <!-- 
End Slider -->


Can we run this code for the current publisher

goffy

Just can't stay away
Posted on: 2019/6/20 11:48
goffy
goffy (Show more)
Just can't stay away
Posts: 418
Since: 2010/12/27
#2

Re: Publisher SliderProblem

hi

1) I do not know which file you mean? want do you want to achieve?
2) did you try the code? try and error is the best teacher I learned php also myself most with try and error but ofcourse I am always willy to help

kind regards
goffy

goffy

Just can't stay away
Posted on: 2019/6/20 11:56
goffy
goffy (Show more)
Just can't stay away
Posts: 418
Since: 2010/12/27
#3

Re: Publisher SliderProblem

hi

btw you should try to split php and html code - create a tpl-file and assign with smarty vars is the better way

iHackCode

Module Developer
Posted on: 6/28 4:15
iHackCode
iHackCode (Show more)
Module Developer
Posts: 1037
Since: 2004/6/29
#4

Re: Publisher SliderProblem

Try this.

<{php}>
use 
XoopsModules\Publisher;
use 
XoopsModules\Publisher\Constants;

$helper Publisher\Helper::getInstance();
$myts =& MyTextSanitizer::getInstance();
$itemsObj $helper->getHandler('Item')->getItems($limit 10$start 0, [Constants::PUBLISHER_STATUS_PUBLISHED], -1$sort 'datesub'$order='DESC'''true$criteria null);
$totalItems count($itemsObj);

global 
$items;
$items = array();
if (
$itemsObj) {
    for ( 
$i 0$i $totalItems$i++ ) {
        
$newItems['itemid']       = $itemsObj[$i]->itemid();
        
$newItems['title']        = $itemsObj[$i]->title();
        
$newItems['body']         = $itemsObj[$i]->body();
        
$newItems['votes']        = $itemsObj[$i]->votes();
        
$newItems['image']        = XOOPS_URL '/uploads/blank.gif';
        
$images $itemsObj[$i]->getImages();
        if (
is_object($images['main'])) {
            
$newItems['image'] = XOOPS_URL '/uploads/' $images['main']->getVar('image_name');
        }
    
$items[] = $newItems;
    }
}
<{/
php}>
<!-- 
Slider -->
    <
div id="slider">
        <
a href="#" id="prev" class="notext"></a>
        <
a href="#" id="next" class="notext"></a>
        
        <
div id="slider-content">
            <
ul>
            <{
php}>
        foreach ( 
$GLOBALS['items'] as $myrow )
        {
            
$GLOBALS['xoopsTpl']->assign('itemid'$myrow['itemid']);
            
$GLOBALS['xoopsTpl']->assign('title'$myrow['title']);
            
$GLOBALS['xoopsTpl']->assign('body'$myrow['body']);
            
$GLOBALS['xoopsTpl']->assign('votes'$myrow['votes']);
            
$GLOBALS['xoopsTpl']->assign('image'$myrow['image']);
        <{/
php}>
            <
li>
                <
div class="left-side">
                    <
a href="<{$xoops_url}>/modules/publisher/item.php?itemid=<{$itemid}>"><img src="<{$image}>" alt="<{$title}>" width="400px" height="200px"/></a>
                </
div>
                
                <
div class="right-side" >
                    <
h1><a  href="<{$xoops_url}>/modules/publisher/item.php?itemid=<{$itemid}>" title="<{$title}>"><{$title}></h1>
                    <
p><{$body|truncate:220}></p>
                    
                    <
class="readmore"><a style="color:#ff0000" href="<{$xoops_url}>/modules/publisher/item.php?itemid=<{$itemid}>">ÊÊãÉ &raquo;</a></p>
                </
div>
                
                <
div class="cl">&nbsp;</div>
            </
li>
        <{
php}>
        }
        <{/
php}> 
            </
ul>
        </
div>
    </
div>
    <!-- 
End Slider -->

heyula

Theme Designer
Posted on: 6/28 10:57
heyula
heyula (Show more)
Theme Designer
Posts: 486
Since: 2008/4/24
#5

Re: Publisher SliderProblem

Hi iHackCode

yes this code worked very thanks

Yurdal

Friend of XOOPS
Posted on: 6/29 19:29
Yurdal
Yurdal (Show more)
Friend of XOOPS
Posts: 367
Since: 2005/3/27
#6

Re: Publisher SliderProblem

Hi Eren, what is the filename you are altering ?
Please share with us , maybe it become handy for future use