Hello everyone,
I'm trying to develop my own component, however, I'm encountering difficulties in understanding how to create it.
I have already read the FAQ on component creation, the J4.x component creation article, searched the internet, asked Gemini and ChatGPT, but I can't make progress.
My project structure is as follows:At this moment, I can display static data in a datatable on my component's admin panel.
What do I want?
I need to code a CRUD for the table that I created and send data to the component to display it on the site section.
I don't want someone to develop my component. I just want to fix the problems I'm encountering and understand how to complete my task.
I would really appreciate it if someone could spare their time to show me a way to solve this because I don't have anyone to do it for me at the moment.
administrator/components/com_aniversariantes/src/Controller/DisplayController.phpadministrator/components/com_aniversariantes/src/view/HtmlView.phpadministrator/components/com_aniversariantes/tmpl/aniversariantes/default.php
I'm trying to develop my own component, however, I'm encountering difficulties in understanding how to create it.
I have already read the FAQ on component creation, the J4.x component creation article, searched the internet, asked Gemini and ChatGPT, but I can't make progress.
My project structure is as follows:
Code:
administrator/components/com_aniversariantes/services/provider.phpadministrator/components/com_aniversariantes/sql/install.mysql.utf8.sqladministrator/components/com_aniversariantes/src/Controller/DisplayController.phpadministrator/components/com_aniversariantes/src/view/HtmlView.phpadministrator/components/com_aniversariantes/tmpl/aniversariantes/default.phpadministrator/components/com_aniversariantes/aniversariantes.xmlcomponents/com_aniversariantes/src/Controller/DisplayController.phpcomponents/com_aniversariantes/view/Aniversariantes/HtmlView.phpcomponents/com_aniversariantes/tmpl/aniversariantes/default.php
What do I want?
I need to code a CRUD for the table that I created and send data to the component to display it on the site section.
I don't want someone to develop my component. I just want to fix the problems I'm encountering and understand how to complete my task.
I would really appreciate it if someone could spare their time to show me a way to solve this because I don't have anyone to do it for me at the moment.
administrator/components/com_aniversariantes/src/Controller/DisplayController.php
Code:
<?phpnamespace Astatonn\Component\Aniversariantes\Administrator\Controller;defined('_JEXEC') or die;use Joomla\CMS\MVC\Controller\BaseController;/** * @package Joomla.Administrator * @subpackage com_aniversariantes * * @copyright Copyright (C) 2024 Astatonn. All rights reserved. * @license GNU General Public License version 3; see LICENSE *//** * Default Controller of Aniversariantes component * * @package Joomla.Administrator * @subpackage com_aniversariantes */class DisplayController extends BaseController { /** * The default view for the display method. * * @var string */ protected $default_view = 'aniversariantes'; public function display($cachable = false, $urlparams = array()) { return parent::display($cachable, $urlparams); } }
Code:
<?phpnamespace Astatonn\Component\Aniversariantes\Administrator\View\Aniversariantes;defined('_JEXEC') or die;use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;/** * @package Joomla.Administrator * @subpackage com_aniversariantes * * @copyright Copyright (C) 2024 Lucas de Souza Silva Lima. All rights reserved. * @license GNU General Public License version 3; see LICENSE *//** * Main "Aniversariantes" Admin View */class HtmlView extends BaseHtmlView { /** * Display the main "Aniversariantes" view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * @return void */ function display($tpl = null) { parent::display($tpl); }}
Code:
<?php/** * @package Joomla.Administrator * @subpackage com_aniversariantes * * @copyright Copyright (C) 2024 Astatonn. All rights reserved. * @license GNU General Public License version 3; see LICENSE */// No direct access to this filedefined('_JEXEC') or die('Restricted Access');// use Joomla\CMS\Factory;// use Joomla\CMS\Categories\Categories;// $db = Factory::getContainer()->get(DatabaseInterface::class);?><div class="container"> <div class="title"> <h1>Aniversariantes</h1> </div> <section> <div class="btn">Adicionar Novo</div> </section> <div class="table-aniversariantes margin-table"> <table class="table" id="tabela"> <thead> <tr> <th>P/G</th> <th>NOME</th> <th>ANIVERSÁRIO</th> <th>AÇÕES</th> </tr> </thead> <tbody> <tr> <td>Row 1 Data 1</td> <td>Row 1 Data 2</td> <td>Row 1 Data 3</td> <td>Row 1 Data 4</td> </tr> <tr> <td>Row 2 Data 1</td> <td>Row 2 Data 2</td> <td>Row 2 Data 3</td> <td>Row 2 Data 4</td> </tr> </tbody> </table> </div> <script src="//cdn.datatables.net/1.13.7/js/jquery.dataTables.min.js"> </script> <link rel="stylesheet" href="//cdn.datatables.net/1.13.7/css/jquery.dataTables.min.css"> <script> $(document).ready(function() { let table = new DataTable('#tabela'); }); </script></div>
Statistics: Posted by astatonn — Tue Feb 13, 2024 10:12 pm