C3 Front End Model for Item, Test: localhost/index.php?option=com_depot&view=part&id=1
This commit is contained in:
25
site/src/Controller/DisplayController.php
Normal file
25
site/src/Controller/DisplayController.php
Normal 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);
|
||||
}
|
||||
}
|
41
site/src/Model/PartModel.php
Normal file
41
site/src/Model/PartModel.php
Normal 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;
|
||||
}
|
||||
}
|
27
site/src/View/Part/HtmlView.php
Normal file
27
site/src/View/Part/HtmlView.php
Normal 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);
|
||||
}
|
||||
}
|
15
site/tmpl/part/default.php
Normal file
15
site/tmpl/part/default.php
Normal 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>
|
Reference in New Issue
Block a user