O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

3. trimiterea datelor la vederi

13 visualizações

Publicada em

http://www.rraducanu.ro

Publicada em: Educação
  • Login to see the comments

  • Seja a primeira pessoa a gostar disto

3. trimiterea datelor la vederi

  1. 1. Trimiterea datelor la vederi
  2. 2. Creati modulul Vederi: si apoi efectuati toate configurarile necesare.
  3. 3. Observam ca avem 2 module care sunt “legate” de pagina root a aplicatiei. Aplica va “alege” pagina care o va afisa la adresa: http://localhost:8080/ in functie de ultimul modul din /config/autoload/modules.config.php return [ ……………………………….. 'Application', 'Test', 'Vederi', ]; In acest caz va incarca pagina root a modulului “Vederi”. Modificai ordinea modulelor si vizualizati: http://localhost:8080/
  4. 4. Creati controller-ul HomeController
  5. 5. HomeController <?php namespace VederiController; use ZendMvcControllerAbstractActionController; use ZendViewModelViewModel; class WelcomeController extends AbstractActionController { public function indexAction() { $viewModel = new ViewModel(); $viewModel->setTemplate(‘vederi/home/index'); return $viewModel; } }
  6. 6. Module/Test/config/module.config.php …………………………………. return [ 'router' => [ 'routes' => [ 'home' => [ 'type' => Literal::class, 'options' => [ 'route' => '/', 'defaults' => [ 'controller' => ControllerIndexController::class, 'action' => 'index', ], ], ], /////////////////////////////////////////////// 'homeee' => [ 'type' => Literal::class, 'options' => [ 'route' => '/home', 'defaults' => [ 'controller' => ControllerHomeController::class, 'action' => 'index', ], ], ], /////////////////////////////// …………………………………………………………………………………………….
  7. 7. ……………………………………. 'controllers' => [ 'factories' => [ ControllerIndexController::class => InvokableFactory::class, ControllerHomeController::class => InvokableFactory::class, ], ], …………………………….
  8. 8. ……………………………………. 'view_manager' => [ 'display_not_found_reason' => true, 'display_exceptions' => true, 'doctype' => 'HTML5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', 'template_map' => [ 'layout/layout' => __DIR__ . '/../view/layout/layout.phtml', 'test/index/index' => __DIR__ . '/../view/test/index/index.phtml', ‘vederi/home/index' => __DIR__ . '/../view/vederi/home/index.phtml', 'error/404' => __DIR__ . '/../view/error/404.phtml', 'error/index' => __DIR__ . '/../view/error/index.phtml', ], …………………………….
  9. 9. • Creati directorul /module/Test/view/vederi/home si in acesta fisierul index.html in care scrieti: <h1>HOME!</h1> <br/><br/> <a href="../">Back</a> http://localhost:8080/welcome
  10. 10. /module/Test/view/vederi/index/index.phtml <html> <head></head> <body bgcolor="aquamarine"> <h1 style="text-align: center;"><font color="blue">URA!!!</font></h1> <br/><br/> <a href="/home">Home page</a> </body> </html>
  11. 11. HomeController …………………. public function numeAction() { $name="Popescu Bogdan"; //$name="Popescu <span style='color:red'>Bogdan</span>"; $viewModel = new ViewModel(array('name' => $name)); $viewModel->setTemplate('vederi/home/test'); return $viewModel; } …………………………….
  12. 12. View/vederi/home/test.phtml <h1>Welcome <?php echo $this->name;?></h1> <br/><br/> <a href="../">Back</a>
  13. 13. Module/vederi/config/module.config.php ……………… 'test' => [ 'type' => Literal::class, 'options' => [ 'route' => '/test', 'defaults' => [ 'controller' => ControllerHomeController::class, 'action' => 'nume', ], ], ], …………………………………….
  14. 14. …………………….. 'view_manager' => [ 'display_not_found_reason' => true, 'display_exceptions' => true, 'doctype' => 'HTML5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', 'template_map' => [ 'layout/layout' => __DIR__ . '/../view/layout/layout.phtml', 'vederi/index/index' => __DIR__ . '/../view/vederi/index/index.phtml', 'vederi/home/index' => __DIR__ . '/../view/vederi/home/index.phtml', 'vederi/home/test' => __DIR__ . '/../view/vederi/home/test.phtml', 'error/404' => __DIR__ . '/../view/error/404.phtml', 'error/index' => __DIR__ . '/../view/error/index.phtml', ],
  15. 15. HomeController …………………. public function prenumeAction() { $data=array('nume'=>'Popescu','prenume'=>'Bogdan'); $viewModel = new ViewModel(array('data' => $data)); $viewModel->setTemplate('vederi/home/data'); return $viewModel; }…………………………….
  16. 16. View/vederi/home/data.phtml <h1>Welcome <?php echo $this->data['nume']." ".$this->data['prenume'];?> </h1> <br/><br/> <a href="../">Back</a>
  17. 17. Module/vederi/config/module.config.php ……………… ‘data' => [ 'type' => Literal::class, 'options' => [ 'route' => '/data', 'defaults' => [ 'controller' => ControllerHomeController::class, 'action' => 'prenume', ], ], ],…………………………………….
  18. 18. …………………….. 'view_manager' => [ 'display_not_found_reason' => true, 'display_exceptions' => true, 'doctype' => 'HTML5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', 'template_map' => [ 'layout/layout' => __DIR__ . '/../view/layout/layout.phtml', 'vederi/index/index' => __DIR__ . '/../view/vederi/index/index.phtml', 'vederi/home/index' => __DIR__ . '/../view/vederi/home/index.phtml', 'vederi/home/test' => __DIR__ . '/../view/vederi/home/test.phtml', 'vederi/home/data' => __DIR__ . '/../view/vederi/home/data.phtml', 'error/404' => __DIR__ . '/../view/error/404.phtml', 'error/index' => __DIR__ . '/../view/error/index.phtml', ],

×