Guest User

Untitled

a guest
Jul 23rd, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.06 KB | None | 0 0
  1.  /**
  2.      * @var \App\Components\IArticleMenuFactory
  3.      * @inject
  4.      */
  5.    
  6.     public $articleMenuFactory;
  7.    
  8.     protected function createComponentArticleMenu()
  9.     {
  10.     $this->articleMenuFactory->create();
  11.     }
  12.  
  13. Ruční vykreslení zatím s controlem (pokud tam uvedu tu mojí komponentu, tak na mě řve, že nebyla vytvořená)
  14.  
  15. {* Latte template *}
  16.  
  17. {block content}
  18. <br /> <br />
  19. <div id='artIconMenu'></div>
  20. <div class="main"><h3>Nový článek:</h3> <br />
  21.  
  22.  {$presenter['addArticle']->render('begin')}
  23. {if !empty($presenter['addArticle']->errors)}
  24.     <div>
  25.         {foreach $presenter['addArticle']->errors AS $error}
  26.             {$error}<br>
  27.         {/foreach}
  28.     </div>
  29. {/if}
  30.  
  31. <table class='addMenuArt'>
  32.    <tr>
  33.     <td>{$presenter['addArticle']['title']->label}</td>
  34.     <td>{$presenter['addArticle']['title']->control}</td>
  35.  
  36.     <td>{$presenter['addArticle']['published']->label}</td>
  37.     <td>{$presenter['addArticle']['published']->control}</td>
  38.     <td>{control articleMenu}</td>
  39.    </tr>
  40. </table>
  41. <table class='addContentArt'>
  42. <tr>
  43.     <td>{$presenter['addArticle']['content']->control}</td>
  44.    
  45. </tr>
  46. </table>
  47.     <div>{$presenter['addArticle']['submit']->control}</div>
  48.  {$presenter['addArticle']->render('end')}
  49. </div>
  50. {/block}
  51.  
  52. ArticleMenu kompomenta (ta co chci zobrazit jednou s buttonkem a jednou bez)
  53.  
  54. <?php
  55.  
  56. namespace App\Components;
  57.  
  58. use Nette\Application\UI\Form;
  59.  
  60. class ArticleMenu extends \Nette\Application\UI\Control  {
  61.  
  62. private $articles;  
  63.  
  64.    
  65. public function __construct(\App\Model\Articles $articles) {
  66.     parent::__construct();
  67.     $this->articles = $articles;
  68.    
  69.  
  70.    
  71. }
  72.      
  73.     protected function createComponentArticleMenu() {
  74.        
  75.      $form = new Form();
  76.      
  77.      $form->addSelect('category','Kategorie', $this->articles->getArticleCategories()->fetchPairs('id', 'name'))
  78.     ->setPrompt('Všechny články');
  79.      $form->addSubmit('addSubmit', 'Zobrazit');
  80.      return $form;
  81. }
  82.  
  83.    
  84.  
  85.     public function render() {
  86.  
  87.     $this['articleMenu']->render();
  88.    
  89.    
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment