2016-08-10 3 views
0

Après je suis joomla « Développer un composant MVC » Document jusqu'à l'étape 15 « Ajout d'ACL »composant Joomla catégorie développement

Link - https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Adding_ACL 

tout fonctionne,

, mais je ne voyais rien de créer frontend catégorie vue, donc j'ajouter une nouvelle vue « catégorie », voici mon code:

dans l'admin dossier champs, je crée un hellocategory.php la plupart du code même avec HelloWord, il suffit de changer

protected $type = 'HelloCategory'; 

/** 
* Method to get a list of options for a list input. 
* 
* @return array An array of JHtml options. 
*/ 
protected function getOptions() 
{ 
    $db = JFactory::getDBO(); 
    $query = $db->getQuery(true); 
    // custom 
    $query->select('#__categories.id as id,#__categories.title as category,#__categories.extension as exten'); 
    $query->from('#__categories'); 
    $query->where($db->quoteName('extension') . ' LIKE '. $db->quote('com_helloworld')); 
    // end custom 
    $db->setQuery((string) $query); 
    $messages = $db->loadObjectList(); 
    $options = array(); 

view.html.php

class HelloWorldViewCategory extends JViewLegacy 
{ 
    /** 
    * Display the Hello World view 
    * 
    * @param string $tpl The name of the template file to parse; automatically searches through the template paths. 
    * 
    * @return void 
    */ 
    function display($tpl = null) 
    { 
     // Assign data to the view 
     $category = $this->get('Item'); 

     // Check for errors. 
     if (count($errors = $this->get('Errors'))) 
     { 
      JLog::add(implode('<br />', $errors), JLog::WARNING, 'jerror'); 

      return false; 
     } 

     // Display the view 
     parent::display($tpl); 
    } 
} 

default.xml

<layout title="Category"> 
     <message>category</message> 
</layout> 
<fields 
     name="request" 
     addfieldpath="/administrator/components/com_helloworld/models/fields" 
     > 
    <fieldset name="request"> 
     <field 
       name="id" 
       type="hellocategory" 
       label="COM_UNOFD_UNOFD_FIELD_GREETING_LABEL" 
       description="COM_UNOFD_UNOFD_FIELD_GREETING_DESC" 
       /> 
    </fieldset> 
</fields> 

default.php

<?php var_dump($category); ?> 

sortie rien, est-il quelque chose au sujet de créer un document de catégorie ou de l'échantillon en ligne? J'ai essayé google pour la solution quatre jours, mais toujours aucune idée, ou le seul w y a-t-il des données de la base de données?

Répondre

0

Fermé,

parce que je l'ai trouvé Joomla stackExange, merci!

le mouvement de question

http://joomla.stackexchange.com/questions/17475/joomla-3-helloworld-component-category