1.3 Zend Framework — Быстрый старт. Создание макета

Zend, “Zend Framework Quick Start. Create A Layout”, public translation into Russian from English More about this translation.

See also 44 similar translations

Translate into another language.

Participants

antdmi 802 points
victor-gryshko 63 points
Join Translated.by to translate! If you already have a Translated.by account, please sign in.
If you do not want to register an account, you can sign in with OpenID.
Pages: previous Ctrl next
1 2 3 4

    01. ; application/configs/application.ini

01. ; application/configs/application.ini

History of edits (Latest: antdmi 7 years, 4 months ago) §

    02.

02.

History of edits (Latest: antdmi 7 years, 4 months ago) §

    03. ; Add to [production] section:

03. ; Add to [production] section:

History of edits (Latest: antdmi 7 years, 4 months ago) §

    04. resources.view[] =

04. resources.view[] =

History of edits (Latest: antdmi 7 years, 4 months ago) §

This tells us to initialize the view with no options (the '[]' indicates that the "view" key is an array, and we pass nothing to it).

Это говорит о том, что вид инициализирован без опций ('[]' указывает, что "view" являеться массивом, и мы ни чего не передаем ему).

History of edits (Latest: antdmi 7 years, 7 months ago) §

Now that we have a view, let's flesh out our _initDoctype() method. In it, we will first ensure the View resource has run, fetch the view object, and then configure it:

Теперь, объект вида, который мы имеем, позволяет полностью завершить наш метод _initDoctype(). В нем, мы сперва убедимся, что ресурс вида (View resource) запущен, выберем объект вида, и потом сконфигурируем его:

History of edits (Latest: antdmi 7 years, 7 months ago) §

    01. // application/Bootstrap.php

01. // application/Bootstrap.php

History of edits (Latest: antdmi 7 years, 4 months ago) §

    02.

02.

History of edits (Latest: antdmi 7 years, 4 months ago) §

    03. class Bootstrap extends Zend_Application_Bootstrap_Bootstrap

03. class Bootstrap extends Zend_Application_Bootstrap_Bootstrap

History of edits (Latest: antdmi 7 years, 4 months ago) §

    04. {

04. {

History of edits (Latest: antdmi 7 years, 4 months ago) §

    05.     protected function _initDoctype()

05. protected function _initDoctype()

History of edits (Latest: antdmi 7 years, 4 months ago) §

    06.     {

06. {

History of edits (Latest: antdmi 7 years, 4 months ago) §

    07.         $this->bootstrap('view');

07. $this->bootstrap('view');

History of edits (Latest: antdmi 7 years, 4 months ago) §

    08.         $view = $this->getResource('view');

08. $view = $this->getResource('view');

History of edits (Latest: antdmi 7 years, 4 months ago) §

    09.       $view->doctype('XHTML1_STRICT');

09. $view->doctype('XHTML1_STRICT');

History of edits (Latest: antdmi 7 years, 4 months ago) §

    10.     }

10. }

History of edits (Latest: antdmi 7 years, 4 months ago) §

    11. }

11. }

History of edits (Latest: antdmi 7 years, 4 months ago) §

Now that we've initialized Zend_Layout and set the Doctype, let's create our site-wide layout:

Теперь, когда мы инициализировали Zend_Layout и установили Doctype, давайте создадим наш макет сайта:

History of edits (Latest: antdmi 7 years, 7 months ago) §

    01. <!-- application/layouts/scripts/layout.phtml -->

01. <!-- application/layouts/scripts/layout.phtml -->

History of edits (Latest: antdmi 7 years, 4 months ago) §

    02. <?php echo $this->doctype() ?>

02. <?php echo $this->doctype() ?>

History of edits (Latest: antdmi 7 years, 4 months ago) §

    03. <html xmlns="http://www.w3.org/1999/xhtml">

03. <html xmlns="http://www.w3.org/1999/xhtml">

History of edits (Latest: antdmi 7 years, 4 months ago) §

    04. <head>

04. <head>

History of edits (Latest: antdmi 7 years, 4 months ago) §

    05. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

05. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

History of edits (Latest: antdmi 7 years, 4 months ago) §

    06. <title>Zend Framework Quickstart Application</title>

06. <title>Приложение Zend Framework — Быстрый старт</title>

History of edits (Latest: antdmi 7 years, 4 months ago) §

    07. <?php echo $this->headLink()->appendStylesheet('/css/global.css') ?>

07. <?php echo $this->headLink()->appendStylesheet('/css/global.css') ?>

History of edits (Latest: antdmi 7 years, 4 months ago) §

    08. </head>

08. </head>

History of edits (Latest: antdmi 7 years, 4 months ago) §

    09. <body>

09. <body>

History of edits (Latest: antdmi 7 years, 4 months ago) §

    10. <div id="header" style="background-color: #EEEEEE; height: 30px;">

10. <div id="header" style="background-color: #EEEEEE; height: 30px;">

History of edits (Latest: antdmi 7 years, 4 months ago) §

    11.     <div id="header-logo" style="float: left">

11. <div id="header-logo" style="float: left">

History of edits (Latest: antdmi 7 years, 4 months ago) §

    12.         <b>ZF Quickstart Application</b>

12. <b>ZF Quickstart Application</b>

History of edits (Latest: antdmi 7 years, 4 months ago) §

    13.     </div>

13. </div>

History of edits (Latest: antdmi 7 years, 4 months ago) §

    14.     <div id="header-navigation" style="float: right">

14. <div id="header-navigation" style="float: right">

History of edits (Latest: antdmi 7 years, 4 months ago) §

    15.         <a href="<?php echo $this->url(

15. <a href="<?php echo $this->url(

History of edits (Latest: antdmi 7 years, 4 months ago) §

    16.             array('controller'=>'guestbook'),

16. array('controller'=>'guestbook'),

History of edits (Latest: antdmi 7 years, 4 months ago) §

    17.             'default',

17. 'default',

History of edits (Latest: antdmi 7 years, 4 months ago) §

    18.             true) ?>">Guestbook</a>

18. true) ?>">Guestbook</a>

History of edits (Latest: antdmi 7 years, 4 months ago) §

    19.     </div>

19. </div>

History of edits (Latest: antdmi 7 years, 4 months ago) §

    20. </div>

20. </div>

History of edits (Latest: antdmi 7 years, 4 months ago) §

    21.

21.

History of edits (Latest: antdmi 7 years, 4 months ago) §

    22. <?php echo $this->layout()->content ?>

22. <?php echo $this->layout()->content ?>

History of edits (Latest: antdmi 7 years, 4 months ago) §

    23.

23.

History of edits (Latest: antdmi 7 years, 4 months ago) §

    24. </body>

24. </body>

History of edits (Latest: antdmi 7 years, 4 months ago) §

    25. </html>

25. </html>

History of edits (Latest: antdmi 7 years, 4 months ago) §

We grab our application content using the layout() view helper, and accessing the "content" key. You may render to other response segments if you wish to, but in most cases, this is all that's necessary.

Мы захватываем контент приложения используя помощники вида (view helper) layout(), и доступный ключ "content". Вы можете вывести и другие блоки если захотите этого, но в большинстве случаев этого достаточно.

History of edits (Latest: antdmi 7 years, 7 months ago) §
Pages: previous Ctrl next
1 2 3 4