C3 Front End Model for Item, Test: localhost/index.php?option=com_depot&view=part&id=1

This commit is contained in:
2023-11-19 12:14:40 +01:00
parent bedb36c136
commit 464f7bd1ac
6 changed files with 119 additions and 4 deletions

View File

@ -0,0 +1,25 @@
<?php
/**
* @package Depot.Site
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.14
*/
namespace KW4NZ\Component\Depot\Site\Controller;
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\BaseController;
class DisplayController extends BaseController
{
protected $default_view = 'part';
public function display($cacheable = false, $urlparams = [])
{
return parent::display($cacheable, $urlparams);
}
}

View File

@ -0,0 +1,41 @@
<?php
/**
* @package Depot.Site
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.14
*/
namespace KW4NZ\Component\Depot\Site\Model;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\ItemModel;
class PartModel extends ItemModel
{
public function getItem($pk = null)
{
if ($pk == null) {
$pk = Factory::getApplication()->input->getInt('id');
}
$db = $this->getDatabase();
$query = $db->createQuery()
->select('*')
->from($db->quoteName('#__depot', 'd'))
->where([
$db->quoteName('d.id') . ' = ' . $db->quote($pk),
$db->quoteName('d.state') . ' = 1',
]);
$db->setQuery($query);
$item = $db->loadObject();
return $item;
}
}

View File

@ -0,0 +1,27 @@
<?php
/**
* @package Depot.Site
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.14
*/
namespace KW4NZ\Component\Depot\Site\View\Part;
defined('_JEXEC') or die;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
class HtmlView extends BaseHtmlView
{
protected $item;
public function display($tpl = null)
{
$this->item = $this->get('Item');
parent::display($tpl);
}
}

View File

@ -0,0 +1,15 @@
<?php
/**
* @package Depot.Site
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.14
*/
defined('_JEXEC') or die;
?>
<h1>
<?= $this->item->component_name; ?>
</h1>