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
Introducing to MooZii Opencart - Template MooZiicart create a beautiful website by yourself
By prmindphp Fri 06 Dec 2019 10:47 am Board English Language
0
2332
Fri 06 Dec 2019 10:47 am By prmindphp View Topic Introducing to MooZii Opencart - Template MooZiicart create a beautiful website by yourself
Introducing the new Mindphp.com Webboard system function (phpbb v.3.2)
By mindphp Wed 04 Dec 2019 8:45 pm Board English Language
0
1321
Wed 04 Dec 2019 8:45 pm By mindphp View Topic Introducing the new Mindphp.com Webboard system function (phpbb v.3.2)
Module "Login" of MooZiicart easy to use, just install
By prmindphp Tue 03 Dec 2019 1:32 pm Board English Language
1
1017
Fri 01 Apr 2022 11:13 am By Anonymous View Topic Module "Login" of MooZiicart easy to use, just install
Module "MooZiiCart Search" of MooZiicart for search keywords of what we want
By prmindphp Mon 02 Dec 2019 11:31 am Board English Language
0
3232
Mon 02 Dec 2019 11:31 am By prmindphp View Topic Module "MooZiiCart Search" of MooZiicart for search keywords of what we want
Features Component MooZiiCart in Joomla for create website to sell products online
By prmindphp Sat 30 Nov 2019 7:00 pm Board English Language
2
4829
Wed 08 Apr 2020 6:51 pm By prmindphp View Topic Features Component MooZiiCart in Joomla for create website to sell products online
Business Analyst Training
By NehaaB Fri 29 Nov 2019 5:27 pm Board English Language
0
640
Fri 29 Nov 2019 5:27 pm By NehaaB View Topic Business Analyst Training
Program convert area
By prmindphp Wed 27 Nov 2019 11:26 am Board English Language
0
1195
Wed 27 Nov 2019 11:26 am By prmindphp View Topic Program convert area
Program exchange rate - Information form Bank of Thailand API
By prmindphp Tue 26 Nov 2019 2:34 pm Board English Language
0
1771
Tue 26 Nov 2019 2:34 pm By prmindphp View Topic Program exchange rate - Information form Bank of Thailand API
Tracking Thailand Post Program
By prmindphp Mon 25 Nov 2019 5:47 pm Board English Language
1
2593
Wed 02 Mar 2022 2:50 pm By ColleenCamacho59 View Topic Tracking Thailand Post Program
Square Root Calculate Program
By prmindphp Fri 22 Nov 2019 11:30 am Board English Language
0
1361
Fri 22 Nov 2019 11:30 am By prmindphp View Topic Square Root Calculate Program
The program calculates the mean, the variable, the standard deviation
By prmindphp Fri 22 Nov 2019 11:12 am Board English Language
0
1088
Fri 22 Nov 2019 11:12 am By prmindphp View Topic The program calculates the mean, the variable, the standard deviation
Introducing the new Mindphp.com Webboard system function (phpbb v.3.2)
By numtan5839 Tue 19 Nov 2019 6:06 pm Board English Language
0
980
Tue 19 Nov 2019 6:06 pm By numtan5839 View Topic Introducing the new Mindphp.com Webboard system function (phpbb v.3.2)
The most popular currency pairs in the Forex for new traders
By numtan5839 Mon 18 Nov 2019 5:32 pm Board English Language
1
2132
Fri 28 Jul 2023 6:27 pm By Okudama View Topic The most popular currency pairs in the Forex for new traders
BIG DATA and Hadoop
By Inglejyoti Mon 18 Nov 2019 4:03 pm Board English Language
0
1062
Mon 18 Nov 2019 4:03 pm By Inglejyoti View Topic BIG DATA and Hadoop
The most popular currency in the Forex
By numtan5839 Mon 18 Nov 2019 3:24 pm Board English Language
0
944
Mon 18 Nov 2019 3:24 pm By numtan5839 View Topic The most popular currency in the Forex
How to use the SQRT function in Excel
By numtan5839 Mon 18 Nov 2019 2:46 pm Board English Language
0
780
Mon 18 Nov 2019 2:46 pm By numtan5839 View Topic How to use the SQRT function in Excel
Deposit money into account with Thailand Post by Bank@post service
By numtan5839 Mon 18 Nov 2019 11:42 am Board English Language
0
1774
Mon 18 Nov 2019 11:42 am By numtan5839 View Topic Deposit money into account with Thailand Post by Bank@post service
Benefits and applications of moving averages
By numtan5839 Mon 18 Nov 2019 10:47 am Board English Language
0
637
Mon 18 Nov 2019 10:47 am By numtan5839 View Topic Benefits and applications of moving averages
Moving Average
By numtan5839 Sat 16 Nov 2019 2:45 pm Board English Language
0
813
Sat 16 Nov 2019 2:45 pm By numtan5839 View Topic Moving Average
weighted arithmetic mean
By numtan5839 Sat 16 Nov 2019 11:56 am Board English Language
0
777
Sat 16 Nov 2019 11:56 am By numtan5839 View Topic weighted arithmetic mean