The data can be saved to the database now. Later be made ​​to list the data recorded.

- Start editing files in the folder hello.php controllers.

com_helloworld/controllers/hello.php

 

function display($cachable = false, $urlparams = array()) 
{       
        JRequest::setVar('view','hellos');
        parent::display($cachable, $urlparams); 
}
function add() 
{
        JRequest::setVar('view', 'hello');
        parent::display();

 

- Add files in the folder hellos.php models for retrieving data from the database to do list.

com_helloworld/models/hellos.php

<?php
defined('_JEXEC') or die('Restricted access');
class HelloworldModelHellos extends JModelList 
{    
        public function __construct($config = array()) 
        {
                if(empty($config['filter_fields'])) {
                        $config['filter_fields'] = array(
                                'name', 'name',
                                'detail', 'detail'
                        );
                }
                parent::__construct($config);
        }        
        protected function populateState($ordering = null, $direction = null) 
        {
                $search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
                $this->setState('filter.search', $search);
                parent::populateState('id', 'asc');
        }       
        protected function getListQuery() 
        {
                $db = $this->getDbo();
                $query = $db->getQuery(true);
                $query->select('*')->from('#__helloworld_hello');
                if ($this->getState('filter.search') !== '') {                    
                    $token = $db->Quote('%'.$db->escape($this->getState('filter.search')).'%');
                    $searches    = array();
                    $searches[]    = 'name LIKE '.$token;
                    $searches[]    = 'detail LIKE '.$token;
                    $query->where('('.implode(' OR ', $searches).')');
                }              
                $query->order($db->escape($this->getState('list.ordering', 'id')).' '.$db->escape($this->getState('list.direction', 'ASC')));
                return $query;
        }
}
?>

 

Hellos in the created folder, create a file view.html.php code views.

com_helloworld/views/hellos/view.html.php

<?php
defined('_JEXEC') or die('Restricted access');
class HelloworldViewHellos extends JViewLegacy 
{    
    function display($tpl = null) 
    {
            $this->items = $this->get('Items');
            $this->pagination = $this->get('Pagination');
            $this->state = $this->get('State');
            $this->addToolbar();
            parent::display($tpl);
    }   
    function addToolbar() 
    {
            JToolbarHelper::title('Hello List');
            JToolbarHelper::addNew('add');
            JToolbarHelper::editList('edit');
            JToolbarHelper::deleteList('Are you sure?', 'delete');
    }
}
?>

 

Create a folder and create a file default.php tmpl-in code

com_helloworld/views/hellos/tmpl/default.php

<?php 
defined('_JEXEC') or die;

JHtml::_('behavior.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select');

$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));

?>
<form action="<?php echo JRoute::_('index.php?option=com_helloworld&c=hello');?>" method="post" name="adminForm" id="adminForm">
    <div id="j-main-container">
        
    <div id="filter-bar" class="btn-toolbar">
        <div class="filter-search btn-group pull-left">
            <input type="text" name="filter_search" id="filter_search" placeholder="Search" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" />
      </div>
        <div class="btn-group pull-left">
            <button type="submit" class="btn tip" title="Search"><i class="icon-search"></i></button>
            <button type="button" class="btn tip" onclick="document.id('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
        </div>
    </div>
    <div class="clearfix"></div>
    
    <table class="table table-striped">
        <thead>
            <tr>
                <th width="1%" class="nowrap center">
                    #
                </th>
                <th width="1%" class="nowrap center">
                  <input type="checkbox" name="checkall-toggle" value="" title="<?php echo JText::_('JGLOBAL_CHECK_ALL'); ?>" onclick="Joomla.checkAll(this)" />
                </th>
                <th class="nowrap center" width="20%">
                    <?php echo JHtml::_('grid.sort', 'Name', 'name', $listDirn, $listOrder); ?>
                </th>
                <th class="nowrap center">
                    <?php echo JHtml::_('grid.sort', 'Detail', 'detail', $listDirn, $listOrder); ?>
                </th>
            </tr>
        </thead>
        
        <tfoot>
            <tr>
                <td colspan="4">
                    <?php echo $this->pagination->getListFooter(); ?>
                </td>
            </tr>
        </tfoot>
        
        <tbody>
            <?php 
            foreach ($this->items as $i => $item) {
                $url = JRoute::_('index.php?option=com_helloworld&c=hello&task=edit&cid='.$item->id);
                ?>
            <tr class="row<?php echo $i % 2; ?>">
                <td class="center"><?php echo $i + 1;?></td>
                <td class="center">
                    <?php echo JHtml::_('grid.id', $i, $item->id); ?>
                </td>
                <td class="left">
                    <a href="/<?php echo $url;?>">
                        <?php echo $item->name;?>
                    </a>
                </td>
                <td class="center">
                    <?php echo $item->detail;?>
                </td>
            </tr>
            <?php
            }
            ?>
        </tbody>
    </table>
    
    <input type="hidden" name="task" value="" />
    <input type="hidden" name="boxchecked" value="0" />
    <input type="hidden" name="c" value="hello" />
    <input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
    <input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
    <?php echo JHtml::_('form.token'); ?>
</form>

 

Summary File:

com_helloworld/helloworld.php

com_helloworld/controllers/hello.php

com_helloworld/models/hello.php

com_helloworld/models/forms/hello.xml

com_helloworld/views/hello/view.html.php

com_helloworld/views/hello/tmpl/default.php

 

Display:

 

 

 

Chapter 12 - Editing Component Development

Recent Topics
Subject
Post Reply
Open
Recent
Report A Problem Using The Square Root Calculation Program
By Thanapoom1514 Wed 29 Nov 2023 10:46 am Board English Language
0
1453
Wed 29 Nov 2023 10:46 am By Thanapoom1514 View Topic Report A Problem Using The Square Root Calculation Program
Cyberpanel PHP8.2
By Anonymous Tue 28 Nov 2023 9:44 am Board English Language
1
661
Tue 28 Nov 2023 10:05 am By mindphp View Topic Cyberpanel PHP8.2
Guide to Domain Hosting: Types, Purchasing, and Current Services
By Watkinsayden81 Wed 08 Nov 2023 3:32 pm Board English Language
0
535
Wed 08 Nov 2023 3:32 pm By Watkinsayden81 View Topic Guide to Domain Hosting: Types, Purchasing, and Current Services
Report A Problem Using Program Calculates Tax Withholding
By Thanapoom1514 Thu 26 Oct 2023 11:19 am Board English Language
0
983
Thu 26 Oct 2023 11:19 am By Thanapoom1514 View Topic Report A Problem Using Program Calculates Tax Withholding
Expert Programming Assignment Help: Your Solution to Coding Challenges
By alfredaharnish Thu 19 Oct 2023 1:33 pm Board English Language
1
547
Sat 04 Nov 2023 7:57 pm By Anonymous View Topic Expert Programming Assignment Help: Your Solution to Coding Challenges
Report A Problem Using The Map Location Search Program
By Thanapoom1514 Thu 14 Sep 2023 4:47 pm Board English Language
1
1445
Tue 19 Sep 2023 4:17 pm By veras View Topic Report A Problem Using The Map Location Search Program
setup microsoft 365
By matthewtaylor39 Tue 05 Sep 2023 3:59 pm Board English Language
1
593
Mon 23 Oct 2023 7:14 pm By veras View Topic setup microsoft 365
Report a problem using Program Exchange Rate
By Thanapoom1514 Wed 21 Jun 2023 4:54 pm Board English Language
0
1958
Wed 21 Jun 2023 4:54 pm By Thanapoom1514 View Topic Report a problem using Program Exchange Rate
Where can I download most recent version of MDUpgrade?
By filipetorres Wed 24 May 2023 9:30 pm Board English Language
3
904
Thu 25 May 2023 4:41 pm By mindphp View Topic Where can I download most recent version of MDUpgrade?
How to plan your E-commerce website
By rachaelwools Mon 08 May 2023 5:48 pm Board English Language
1
743
Mon 15 May 2023 4:42 pm By Reginaler View Topic How to plan your E-commerce website
Report a problem, delete usage data in the domain checker program.
By Thanapoom1514 Mon 17 Apr 2023 4:58 pm Board English Language
0
732
Mon 17 Apr 2023 4:58 pm By Thanapoom1514 View Topic Report a problem, delete usage data in the domain checker program.
Report a problem using the QR code generator
By Thanapoom1514 Mon 03 Apr 2023 11:50 am Board English Language
0
827
Mon 03 Apr 2023 11:50 am By Thanapoom1514 View Topic Report a problem using the QR code generator
Report a problem using the domain checker program
By Thanapoom1514 Thu 30 Mar 2023 12:23 pm Board English Language
0
1761
Thu 30 Mar 2023 12:23 pm By Thanapoom1514 View Topic Report a problem using the domain checker program
Choosing The Perfect Venue for Your Special Day in Phuket
By Justastoryteller Wed 29 Mar 2023 9:35 am Board English Language
1
851
Tue 25 Apr 2023 5:40 pm By davidmikejohn View Topic Choosing The Perfect Venue for Your Special Day in Phuket
How to Decorate Your Apartment in Bangkok on a Budget
By pechevill Tue 28 Mar 2023 2:46 pm Board English Language
1
961
Wed 29 Mar 2023 2:43 pm By Justastoryteller View Topic How to Decorate Your Apartment in Bangkok on a Budget
Report a problem using the EAN-13 barcode generator program
By Thanapoom1514 Tue 28 Mar 2023 11:08 am Board English Language
0
1642
Tue 28 Mar 2023 11:08 am By Thanapoom1514 View Topic Report a problem using the EAN-13 barcode generator program
Report a problem using the program to calculate the air conditioning (BTU)
By Tookta Tue 28 Feb 2023 10:13 am Board English Language
0
2216
Tue 28 Feb 2023 10:13 am By Tookta View Topic Report a problem using the program to calculate the air conditioning (BTU)
Report an issue with the taxi rate calculation program
By flook Tue 21 Feb 2023 11:59 am Board English Language
0
1508
Tue 21 Feb 2023 11:59 am By flook View Topic Report an issue with the taxi rate calculation program
Report a problem using the Program for calculating land price per unit
By Thanapoom1514 Mon 20 Feb 2023 10:54 am Board English Language
0
2815
Mon 20 Feb 2023 10:54 am By Thanapoom1514 View Topic Report a problem using the Program for calculating land price per unit
Report a problem using the total land price calculation program
By Thanapoom1514 Mon 20 Feb 2023 10:24 am Board English Language
0
1387
Mon 20 Feb 2023 10:24 am By Thanapoom1514 View Topic Report a problem using the total land price calculation program