C3 Front End Model for Item, Test: localhost/index.php?option=com_depot&view=part&id=1
This commit is contained in:
parent
bedb36c136
commit
464f7bd1ac
@ -49,7 +49,7 @@ CREATE TABLE `#__depot` (
|
||||
INSERT INTO `#__depot` (`component_name`,`alias`,`description`,`quantity`,`created`,
|
||||
`ordering`,`state`,`manufacturer_id`,`stock_id`,`package_id`) VALUES
|
||||
('1N5404','1n5404','diode, rectifier 3A',9,'2023-09-25 15:00:00',1,1,1,1,9),
|
||||
('1N4148','1n4148','diode, general purpose',1234,'2023-09-25 15:15:15',2,1,2,1,8)
|
||||
('1N4148','1n4148','diode, general purpose',1234,'2023-09-25 15:15:15',2,1,2,1,8),
|
||||
('R_120R','r_120r','resistor, metalic',46,'2023-11-15 23:40:00',3,1,1,2,11);
|
||||
|
||||
DROP TABLE IF EXISTS `#__depot_manufacturer`;
|
||||
|
13
depot.xml
13
depot.xml
@ -2,12 +2,12 @@
|
||||
<extension type="component" method="upgrade">
|
||||
<name>Depot</name>
|
||||
<author>KW4NZ</author>
|
||||
<creationDate>2023-11-18</creationDate>
|
||||
<creationDate>2023-11-19</creationDate>
|
||||
<copyright>(C) KW4NZ Thomas Kuschel</copyright>
|
||||
<license>GPL v2 +; see LICENSE.md</license>
|
||||
<authorEmail>thomas@kuschel.at</authorEmail>
|
||||
<authorUrl>https://kuschel.at</authorUrl>
|
||||
<version>0.9.13</version>
|
||||
<version>0.9.14</version>
|
||||
<description>COM_DEPOT_XML_DESCRIPTION</description>
|
||||
<namespace path="src/">KW4NZ\Component\Depot</namespace>
|
||||
<install> <!-- Runs on install -->
|
||||
@ -25,10 +25,17 @@
|
||||
<schemapath type="mysql">sql/updates/mysql</schemapath>
|
||||
</schemas>
|
||||
</update>
|
||||
<files folder="site/">
|
||||
<files folder="site">
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
<!--
|
||||
<file>CODING_STANDARDS.md</file>
|
||||
<file>LICENSE.md</file>
|
||||
<file>README.md</file>
|
||||
|
||||
<folder>forms</folder>
|
||||
<folder>language</folder>
|
||||
-->
|
||||
</files>
|
||||
<administration>
|
||||
<!--
|
||||
|
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>
|
Loading…
Reference in New Issue
Block a user