Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [ZendFramework] Nowa podstrona, kontroler, widok
in5ane
post
Post #1





Grupa: Zarejestrowani
Postów: 1 335
Pomógł: 34
Dołączył: 9.11.2005
Skąd: Wrocław

Ostrzeżenie: (10%)
X----


Cześć. Mam pytanie. Czy tworząc nową podstronę, w widoku muszę mięć tak: header/header.phtml (przykładowo inne podstrony działają tak: account/login.php, account/register.php)? A moje pytanie brzmi, czy da radę ustawić, żeby tylko tego headera nie wciskać dodatkowo do folderu?

W headerController.php mam tak:
  1. <?php
  2. class HeaderController extends Zend_Controller_Action {
  3.  
  4.    function init() {
  5.        $this->view->baseUrl = $this->_request->getBaseUrl();
  6.    }
  7.  
  8.    function headerAction() {
  9.        $config = new config();
  10.        $select = $config->select()->where('name = "title"');
  11.        $this->view->row_config = $config->fetchRow($select);
  12.    }
  13.    
  14. }
  15. ?>


No i w widoku tylko:
  1. <?php echo $this->view->row_config; ?>



Oczywiście to musi działać tylko na header, no bo inne podstrony muszą mieć te foldery.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
in5ane
post
Post #2





Grupa: Zarejestrowani
Postów: 1 335
Pomógł: 34
Dołączył: 9.11.2005
Skąd: Wrocław

Ostrzeżenie: (10%)
X----


Troszkę w ogóle przerobiłem sobie to, ale i tak nie działa.

Zrobiłem tak:
LayoutController.php
  1. <?php
  2. class LayoutController extends Zend_Controller_Action {
  3.  
  4.    function init() {
  5.        $this->view->baseUrl = $this->_request->getBaseUrl();
  6.    }
  7.  
  8.    function layoutAction() {
  9.        $config = new config();
  10.        $select = $config->select()->where('name = "title"');
  11.        $this->view->row_config_title = $config->fetchRow($select);
  12.  
  13.        $this->render('layout', null, true);
  14.    }
  15.    
  16. }
  17. ?>


layout.phtml
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2.   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html lang='pl' xml:lang='pl' xmlns='http://www.w3.org/1999/xhtml'>
  4. <head>
  5.    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6.    <title>System of Announcements :: <?php echo $this->escape($this->title); ?></title>
  7.    <link rel="stylesheet" type="text/css" href="<?php echo $this->baseUrl;?>/public/styles/site.css" />
  8. </head>
  9. <body>
  10.  
  11.    <div id="content">
  12.        <div id="content_1">
  13.            <em>wersja beta 0.2</em>
  14.        </div>
  15.        <div id="content_2">
  16.            <?php echo $this->row_config_title->description; ?>
  17.        </div>
  18.        <div id="content_3">
  19.            Menu
  20.        </div>
  21.        <div id="content_4" style="text-align: center;">
  22.            tutaj jakies tam menu, bla bla bla bla....
  23.        </div>
  24.        <?php echo $this->layout()->content; ?>
  25.        <p id="footer">stopka.....</p>
  26.    </div>
  27.  
  28. </body>
  29. </html>


A taki dostaję error:
Kod
Notice: Trying to get property of non-object in C:\wamp\www\application\views\scripts\layout.phtml on line 20


Proszę o pomoc ;-)

Ten post edytował in5ane 1.08.2009, 14:05:44
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 11.03.2026 - 20:00