
I've added support for different field types and integrated Xoops form features. I plan to release it soon. In my opinion, this was one of the major missing features in Xoops.
/** @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);
<{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}>
Mamba wrote:
Eren,
Quote:Download: https://erenyumak.com/Xoops-Admin.zip
First of all, thank you so much for testing and submitting your changes. I love when we get together as a community and get things going!
But this is a perfect opportunity to practice collaboration on GitHub and working with Git.
Just fork it from https://github.com/ForXoops/System, and then submit your changes there! Trust me, it will speed up the development process for all, and it will also help with testing for bugs!
If you need any help with how to work with GitHub and local forks, please let me know, and I'll be happy to help!