1
heyula
PodTalk Theme (PUBLISHER)
  • 2024/11/2 12:20

  • heyula

  • Theme Designer

  • Posts: 605

  • Since: 2008/4/24


"Recently, thanks to an idea Michael came up with for the Publisher module, creating independent blocks has become much easier, and I wanted to test it with a nice theme. Very soon, I will release the PodTalk theme compatible with Publisher."

Resized Image


Demo: https://erenyumak.com/ato/

Code added by Michael to theme_autorun.php

<?php

/** @var XoopsTpl */
global $xoopsTpl;
if (!empty(
$xoopsTpl)) {
    
$xoopsTpl->addConfigDir(__DIR__);
}

require 
dirname(__DIR__,2) . '/modules/publisher/preloads/autoloader.php';

use 
XoopsModulesPublisher{
    
Constants,
    
Helper,
    
Item
};

// Initialize helper and text sanitizer
$myts = MyTextSanitizer::getInstance();

/**
 * Function to fetch items
 */
function getPublisherItems($limit, $sort = 'RAND()', $order = '')
{
    
$helper = Helper::getInstance();
    
$itemsObj = $helper->getHandler('Item')->getItems(
        
$limit,
        
$start = 0,
        [
Constants::PUBLISHER_STATUS_PUBLISHED],
        -
1,
        
$sort,
        
$order,
        
'',
        
true,
        
$criteria = null
    
);

    
$items = [];
    if (
$itemsObj) {
        foreach (
$itemsObj as $itemObj) {
            
$newItem = [
                
'itemid'   => $itemObj->itemid(),
                
'title'    => $itemObj->title(),
                
'body'     => $itemObj->body(),
                
'votes'    => $itemObj->votes(),
                
'counter'  => $itemObj->counter(),
                
'comments' => $itemObj->comments(),
                
'image'    => XOOPS_URL . '/uploads/blank.gif',
            ];

            
$images = $itemObj->getImages();
            if (isset(
$images['main']) && is_object($images['main'])) {
                
$newItem['image'] = XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name');
            }

            
$items[] = $newItem;
        }
    }
    return 
$items;
}

// Fetch and assign items for each template
$xoopsTpl->assign('breakingItems', getPublisherItems(4));
$xoopsTpl->assign('featuredItems', getPublisherItems(3));
$xoopsTpl->assign('fourLastedRandomItems', getPublisherItems(4));
$xoopsTpl->assign('itemBreakingItems', getPublisherItems(10));
$xoopsTpl->assign('lastedRandomItems', getPublisherItems(4));
$xoopsTpl->assign('newsItems', getPublisherItems(4));
$xoopsTpl->assign('oneLastedRandomItem', getPublisherItems(1));
$xoopsTpl->assign('rightLastedRandomItems', getPublisherItems(8));
$xoopsTpl->assign('sliderItems', getPublisherItems(9));

// Assign XOOPS URL
$xoopsTpl->assign('xoops_url', XOOPS_URL);

Example block usage

<{foreach item=item from=$sliderItems}>    
    <
div class="owl-carousel-info-wrap item">
        <
img src="<{$item.image}>"
            
class="owl-carousel-image img-fluid" alt="<{$item.title}>">

        <
div class="owl-carousel-info">
            <
h4 class="mb-2">
                <
a href="<{$xoops_url}>/modules/publisher/item.php?itemid=<{$item.itemid}>">
                    <{
$item.title|truncate:15}>
                </
a>            
                <
img src="<{xoImgUrl}>images/verified.png" class="owl-carousel-verified-image img-fluid" alt="<{$item.title}>">
            </
h4>

            <
span class="badge">Reads: <{$item.counter}></span>

            <
span class="badge">Votes: <{$item.votes}></span>
        </
div>
    </
div>
<{/foreach}>

2
Mamba
Re: PodTalk Theme (PUBLISHER)
  • 2024/11/3 9:27

  • Mamba

  • Moderator

  • Posts: 11552

  • Since: 2004/4/23


Awesome work, thank you so much for making our themes better and better!

I can't wait for the full new theme to test it out!
Support XOOPS => DONATE
Use 2.7.x | Docs | Modules | Bugs