1
Lou86
Last activities / multi modules
  • 2021/4/18 9:06

  • Lou86

  • Just popping in

  • Posts: 1

  • Since: 2021/3/18


Hi,

As I'm using 3 instances of Publisher, I would love to have some blocs (as Latest news or Recent articles) able to list content from the 3 modules. Having the 3 modules separated is a bless for my use but having one list with all contents ordered by post time and not separated by module would be a must.

Do you know if there is already a way to do that? Or have I to make it myself?

Thanks for your help

2
goffy
Re: Last activities / multi modules
  • 2021/4/19 18:06

  • goffy

  • Just can't stay away

  • Posts: 543

  • Since: 2010/12/27


Hi

you can create a custom block, content type "PHP Script"

then add the code for getting data
Quote:

$myts = \MyTextSanitizer::getInstance();
$itemsAll = $newItems = [];
$sort ='datesub';
$order = 'DESC';
$limit = 5;
$start = 0;


/*my first publisher clone*/
$helper = \XoopsModules\Publisher1\Helper::getInstance();
$itemHandler = $helper->getHandler('Item');
$itemsObj = $itemHandler->getItems($limit, $start, [\XoopsModules\Publisher1\Constants::PUBLISHER1_STATUS_PUBLISHED], -1, $sort, $order, '', true);
$totalItems = count($itemsObj);

if ($itemsObj && $totalItems > 0) {
foreach ($itemsObj as $iValue) {
$newItems['source'] ='Publisher1: ';
$newItems['itemid'] = $iValue->itemid();
$newItems['itemlink'] = $iValue->getItemLink(false, $options[3] ?? 65);
$itemsAll[] = $newItems;
}
}
unset($itemsObj, $itemHandler);

/*my second publisher clone*/
$helper = \XoopsModules\Publisher2\Helper::getInstance();
$itemHandler = $helper->getHandler('Item');
$itemsObj = $itemHandler->getItems($limit, $start, [\XoopsModules\Publisher2\Constants::PUBLISHER2_STATUS_PUBLISHED], -1, $sort, $order, '', true);
$totalItems = count($itemsObj);

if ($itemsObj && $totalItems > 0) {
foreach ($itemsObj as $iValue) {
$newItems['source'] ='Publisher2: ';
$newItems['itemid'] = $iValue->itemid();
$newItems['itemlink'] = $iValue->getItemLink(false, $options[3] ?? 65);
$itemsAll[] = $newItems;
}
}
unset($itemsObj, $itemHandler);

/*output of result*/
foreach($itemsAll as $item) {
echo '

' . $item['source'] . $item['itemlink'] . '

';
}


in this example the name of the clones are 'Publisher1' and 'Publisher2'

replace the names by your names of the clones and/or add for each additional publisher clone the adapted code

let me know if it works :)

Login

Who's Online

328 user(s) are online (122 user(s) are browsing Support Forums)


Members: 0


Guests: 328


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits