1

I hope the community can help me. In this project, I would like to use Joomla's user profile view system and display the latest user posts.

I thought maybe it would be doable to create a layout in mod_zooitem and implement a ZOO user's most recent post views model and then enable this module in the user's profile so that if a user wants to see another user's content, can do it.

I have no idea how to apply for such a request, I hope you can help me.

Idea.

/module/mod_itemzoo/mod_itenzoo.php

<?php
/**
 * @package   ZOO Item
 * @author    YOOtheme https://yootheme.com
 * @copyright Copyright (C) YOOtheme GmbH
 * @license   https://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
 */

use Joomla\CMS\Helper\ModuleHelper;

// no direct access
defined('_JEXEC') or die('Restricted access');

// load config
require_once(JPATH_ADMINISTRATOR.'/components/com_zoo/config.php');

// get app
$zoo = App::getInstance('zoo');

// load zoo frontend language file
$zoo->system->language->load('com_zoo');

// init vars
$path = dirname(__FILE__);

//register base path
$zoo->path->register($path, 'mod_zooitem');

if ($application = $zoo->table->application->get($params->get('application', 0))) {

    $items = $zoo->module->getItems($params);

    // set renderer
    $renderer = $zoo->renderer->create('item')->addPath(array($zoo->path->path('component.site:'), dirname(__FILE__)));

    $layout = $params->get('layout', 'default');

    include(ModuleHelper::getLayoutPath('mod_zooitem', $params->get('theme', 'list')));
}

/modules/modules_zooitem/mod_zooitem.xml

<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="3.2" method="upgrade" client="site">
    <name>ZOO Item</name>
    <author>YOOtheme</author>
    <creationDate>August 2022</creationDate>
    <copyright>Copyright (C) YOOtheme GmbH</copyright>
    <license>https://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only</license>
    <assetsLicense>YOOtheme Proprietary Use License (https://yootheme.com/license)</assetsLicense>
    <authorEmail>[email protected]</authorEmail>
    <authorUrl>https://yootheme.com</authorUrl>
    <version>4.1.20</version>
    <description>Item module for ZOO developed by YOOtheme (https://yootheme.com)</description>
    <files>
        <filename module="mod_zooitem">mod_zooitem.php</filename>
        <filename>changelog.php</filename>
        <filename>file.script.php</filename>
        <folder>fields</folder>
        <folder>renderer</folder>
        <folder>tmpl</folder>
    </files>
    <scriptfile>file.script.php</scriptfile>
    <config>
        <fields name="params" >
            <fieldset name="basic" addfieldpath="/modules/mod_zooitem/fields">
                <field name="theme" type="filename" default="" label="Theme" description="Visual style" path="/tmpl/" />
                <field name="layout" type="filename" default="" label="Layout" description="The Item Layout" path="/renderer/item/" />
                <field name="media_position" type="list" default="left" label="Media Position" description="MEDIAPOSITION_DESCRIPTION">
                    <option value="left">Left</option>
                    <option value="right">Right</option>
                    <option value="top">Top</option>
                    <option value="middle">Middle</option>
                    <option value="bottom">Bottom</option>
                </field>
                <field name="application" type="zooapplication" default="" label="Items" description="APPLICATION_DESCRIPTION" categories="true" frontpage="true" items="true" types="true" />
                <field name="mode" type="hidden" label="" required="false" description="" />
                <field name="type" type="hidden" label="" required="false" description="" />
                <field name="category" type="hidden" label="" required="false" description="" />
                <field name="item_id" type="hidden" label="" required="false" description="" />
                <field name="subcategories" type="radio" default="0" label="Include Subcategories" description="SUBCATEGORY_DESCRIPTION">
                    <option value="0">JNO</option>
                    <option value="1">JYES</option>
                </field>
                <field name="count" type="text" default="4" size="5" label="Item Count" description="Maximum number of items to display" />
                <field name="order" type="zooitemorder" default="_itemname" label="Item Order" description="ITEM_ORDER" apps="true" random="true" />
                <field name="moduleclass_sfx" type="text" default="" label="Module Class Suffix" description="" />
            </fieldset>
        </fields>
    </config>
</extension>

/modules/mod_zooitem/tmpl/items_users.php

<?php


// no direct access
use Joomla\CMS\Language\Text;

defined('_JEXEC') or die('Restricted access');

$css_class = $application->getGroup().'-'.$application->getTemplate()->name;

?>

<?php if (!empty($items)) : ?>

<ul class="uk-list uk-list-divider <?php echo $css_class ?>">
    <?php $i = 0; foreach ($items as $item) : ?>
    <li><?php echo $renderer->render('item.'.$layout, compact('item', 'params')); ?></li>
    <?php $i++; endforeach; ?>
</ul>

<?php else : ?>
<?php echo Text::_('COM_ZOO_NO_ITEMS_FOUND'); ?>
<?php endif;

/modules/mod_zooitem/renderer/item/user_items.php

<?php


// no direct access
defined('_JEXEC') or die('Restricted access');

$media_position = $params->get('media_position', 'top');

?>

<div class="layout-default <?php if ($media_position == 'top' || $media_position == 'middle' || $media_position == 'bottom') echo 'alignment-center'; ?>">

    <?php if (($media_position == 'top' || $media_position == 'left' || $media_position == 'right') && $this->checkPosition('media')) : ?>
    <div class="media media-<?php echo $media_position; ?>"><?php echo $this->renderPosition('media'); ?></div>
    <?php endif; ?>
    
    <?php if ($this->checkPosition('title')) : ?>
    <p class="title"><?php echo $this->renderPosition('title'); ?></p>
    <?php endif; ?>
    
    <?php if ($this->checkPosition('meta')) : ?>
    <p class="meta"><?php echo $this->renderPosition('meta', array('style' => 'comma')); ?></p>
    <?php endif; ?>
    
    <?php if (($media_position == 'middle') && $this->checkPosition('media')) : ?>
    <div class="media media-<?php echo $media_position; ?>"><?php echo $this->renderPosition('media'); ?></div>
    <?php endif; ?>
    
    <?php if ($this->checkPosition('description')) : ?>
    <div class="description"><?php echo $this->renderPosition('description', array('style' => 'block')); ?></div>
    <?php endif; ?>
    
    <?php if (($media_position == 'bottom') && $this->checkPosition('media')) : ?>
    <div class="media media-<?php echo $media_position; ?>"><?php echo $this->renderPosition('media'); ?></div>
    <?php endif; ?>
    
    <?php if ($this->checkPosition('links')) : ?>
    <p class="links"><?php echo $this->renderPosition('links', array('style' => 'pipe')); ?></p>
    <?php endif; ?>

</div>

I hope that the community can help me to achieve it since programming is not my field.

10
  • Hmm. I see where $searching is accessed, but I don't see where it is declared. I also see some incorrect string concatenation syntax when cinstructing <li> markup. Do you have error reporting turned on and all the way up? Part of asking a good, narrow, clear question is providing all necessary debugging details so that contributors have the easiest possible time assisting you. Oct 8, 2022 at 0:40
  • @mickmackusa I'm sorry, excuse me, I reformulated the query, I hope that now it will be more useful to you
    – Diego
    Oct 10, 2022 at 11:47
  • Volunteer contributors and future researchers shouldn't need to download a .zip file to understand your question. We'd prefer that all details are statically written as text in the question body (when reasonable). If you cannot narrow your question or you are actually looking for someone else to do your software development, then this community might not be the right place. Oct 10, 2022 at 12:01
  • Thanks for your suggestions, they help me build a solution. I do not intend to make any money from this implementation and I understand that by suggesting it in a public forum even less. I also appreciate your defense towards the sector but I think it is not my case. You can sharpen knives elsewhere.
    – Diego
    Oct 10, 2022 at 14:58
  • I might be asking something silly, but does compact() have access to the $params variable? 3v4l.org/X0o2Z $media_position == 'top' || $media_position == 'left' || $media_position == 'right') can be reduced to in_array($media_position, ['top', 'left', 'right']) Is $items not an indexed array? Do you manually need to increment the counter or can you just declare $i as the key in the foreach() signature? Where exactly does your script fail? Are you able to access the desired data in the view template? or is the data not even available? Did you dump your variables out? Oct 10, 2022 at 21:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.