User Rating: 1 / 5

Star ActiveStar InactiveStar InactiveStar InactiveStar Inactive
 

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
使用 Module M Slideshows 说明手册
By wipaporn Wed 20 Feb 2019 4:56 pm Board Chinese Language - 简体中文
0
20478
Wed 20 Feb 2019 4:56 pm By wipaporn
使用 Component M Multisite Master 说明手册
By wipaporn Wed 20 Feb 2019 4:30 pm Board Chinese Language - 简体中文
0
20025
Wed 20 Feb 2019 4:30 pm By wipaporn
使用 Component M Multisite Client 说明手册
By wipaporn Wed 20 Feb 2019 4:06 pm Board Chinese Language - 简体中文
0
20879
Wed 20 Feb 2019 4:06 pm By wipaporn
Features Review : M MultiSite Content client Komponen untuk merekodkan Nama Domain Master Site
By abdkode Wed 20 Feb 2019 3:51 pm Board Bahasa Language
0
8114
Wed 20 Feb 2019 3:51 pm By abdkode
使用Module MDFiles Popular 说明手册
By wipaporn Wed 20 Feb 2019 3:35 pm Board Chinese Language - 简体中文
0
24425
Wed 20 Feb 2019 3:35 pm By wipaporn
Features Review : MDFiles Documents membantu menghubungkan artikel ke Component MDFiles
By abdkode Wed 20 Feb 2019 3:33 pm Board Bahasa Language
0
4740
Wed 20 Feb 2019 3:33 pm By abdkode
使用 Module MDFiles Featured 说明手册
By wipaporn Wed 20 Feb 2019 3:04 pm Board Chinese Language - 简体中文
0
25207
Wed 20 Feb 2019 3:04 pm By wipaporn
使用Module MDFiles Categories 说明手册
By wipaporn Wed 20 Feb 2019 2:31 pm Board Chinese Language - 简体中文
0
21953
Wed 20 Feb 2019 2:31 pm By wipaporn
使用 Module MDfiles recent 说明手册
By wipaporn Wed 20 Feb 2019 2:29 pm Board Chinese Language - 简体中文
0
24173
Wed 20 Feb 2019 2:29 pm By wipaporn
使用Component MDFiles说明手册
By wipaporn Wed 20 Feb 2019 12:10 pm Board Chinese Language - 简体中文
0
10843
Wed 20 Feb 2019 12:10 pm By wipaporn
使用 Component MJForm 说明手册
By wipaporn Wed 20 Feb 2019 12:03 pm Board Chinese Language - 简体中文
0
23270
Wed 20 Feb 2019 12:03 pm By wipaporn
Features Review : Plugin Editors XTD Multicontent untuk mengeluarkan artikel dari Master Site ke Web Clien
By abdkode Tue 19 Feb 2019 6:52 pm Board Bahasa Language
0
6549
Tue 19 Feb 2019 6:52 pm By abdkode
Features Review : Mod MDFiles Popular modul menyenaraikan fail popular
By abdkode Tue 19 Feb 2019 5:41 pm Board Bahasa Language
0
5504
Tue 19 Feb 2019 5:41 pm By abdkode
Features Review : Mod MDFiles Featured memaparkan fail-fail yang dipilih dari MDFile untuk dipaparkan pada Joomla
By abdkode Tue 19 Feb 2019 4:39 pm Board Bahasa Language
0
2798
Tue 19 Feb 2019 4:39 pm By abdkode
Features Review : Components Mjform komponen untuk membuat borang laman web
By abdkode Tue 19 Feb 2019 3:23 pm Board Bahasa Language
0
2709
Tue 19 Feb 2019 3:23 pm By abdkode
Mod MDFiles Popular 모듈 소개 MDFile에서 파일을 가져와 표시
By wipaporn Fri 15 Feb 2019 6:06 pm Board korean Language - 한국어
0
6509
Fri 15 Feb 2019 6:06 pm By wipaporn
MDFiles Featured modules를 소개하면 MDFile에서 파일을 가져와 보여준다.
By wipaporn Fri 15 Feb 2019 6:06 pm Board korean Language - 한국어
0
6145
Fri 15 Feb 2019 6:06 pm By wipaporn
마스터 사이트에서 Web Client로 문서를 끌어오기 위한 플러그인인 Editors XTD Multicontent를 소개한다.
By wipaporn Fri 15 Feb 2019 5:48 pm Board korean Language - 한국어
0
2067
Fri 15 Feb 2019 5:48 pm By wipaporn
Joomla 1.5를 Joomla 2.5, 3.X로 업그레이드하기 위한 MJUpgrade 소개
By wipaporn Fri 15 Feb 2019 5:36 pm Board korean Language - 한국어
0
2433
Fri 15 Feb 2019 5:36 pm By wipaporn
MApplication Form Components를 소개한다. 구직 신청서는 웹사이트를 통해 작성된다.
By wipaporn Fri 15 Feb 2019 5:27 pm Board korean Language - 한국어
0
2259
Fri 15 Feb 2019 5:27 pm By wipaporn