Skip to content
This repository has been archived by the owner on Dec 30, 2023. It is now read-only.

Commit

Permalink
Explained the difference between Mvc\\View and Mvc\\View\\Simple's re…
Browse files Browse the repository at this point in the history
…nder() method (#329, #405)
  • Loading branch information
SidRoberts committed Oct 17, 2015
1 parent b081717 commit 1381b41
Show file tree
Hide file tree
Showing 16 changed files with 336 additions and 0 deletions.
26 changes: 26 additions & 0 deletions en/reference/micro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,32 @@ Rendering Views
});
Please note that this code block uses :doc:`Phalcon\\Mvc\\View\\Simple <../api/Phalcon_Mvc_View_Simple>` which uses relative paths instead of controllers and actions.
If you would like to use :doc:`Phalcon\\Mvc\\View\\Simple <../api/Phalcon_Mvc_View_Simple>` instead, you will need to change the parameters of the :code:`render()` method:

.. code-block:: php
<?php
$app = new Phalcon\Mvc\Micro();
$app['view'] = function () {
$view = new \Phalcon\Mvc\View();
$view->setViewsDir('app/views/');
return $view;
};
// Return a rendered view
$app->get('/products/show', function () use ($app) {
// Render app/views/products/show.phtml passing some variables
echo $app['view']->render('products', 'show', array(
'id' => 100,
'name' => 'Artichoke'
));
});
Error Handling
--------------
A proper response can be generated if an exception is raised in a micro handler:
Expand Down
16 changes: 16 additions & 0 deletions en/reference/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,22 @@ To render a view it's necessary to call the render method explicitly indicating
}
}
This is different to :doc:`Phalcon\\Mvc\\View <../api/Phalcon_Mvc_View>` who's :code:`render()` method uses controllers and actions as parameters:

.. code-block:: php
<?php
$params = array('posts' => Posts::find());
// Phalcon\Mvc\View
$view = new \Phalcon\Mvc\View();
echo $view->render('posts', 'show', $params);
// Phalcon\Mvc\View\Simple
$simpleView = new \Phalcon\Mvc\View\Simple();
echo $simpleView->render('posts/show', $params);
Using Partials
--------------
Partial templates are another way of breaking the rendering process into simpler more manageable chunks that can be reused by different
Expand Down
26 changes: 26 additions & 0 deletions es/reference/micro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,32 @@ Rendering Views
});
Please note that this code block uses :doc:`Phalcon\\Mvc\\View\\Simple <../api/Phalcon_Mvc_View_Simple>` which uses relative paths instead of controllers and actions.
If you would like to use :doc:`Phalcon\\Mvc\\View\\Simple <../api/Phalcon_Mvc_View_Simple>` instead, you will need to change the parameters of the :code:`render()` method:

.. code-block:: php
<?php
$app = new Phalcon\Mvc\Micro();
$app['view'] = function () {
$view = new \Phalcon\Mvc\View();
$view->setViewsDir('app/views/');
return $view;
};
// Return a rendered view
$app->get('/products/show', function () use ($app) {
// Render app/views/products/show.phtml passing some variables
echo $app['view']->render('products', 'show', array(
'id' => 100,
'name' => 'Artichoke'
));
});
Error Handling
--------------
A proper response can be generated if an exception is raised in a micro handler:
Expand Down
16 changes: 16 additions & 0 deletions es/reference/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,22 @@ To render a view it's necessary to call the render method explicitly indicating
}
}
This is different to :doc:`Phalcon\\Mvc\\View <../api/Phalcon_Mvc_View>` who's :code:`render()` method uses controllers and actions as parameters:

.. code-block:: php
<?php
$params = array('posts' => Posts::find());
// Phalcon\Mvc\View
$view = new \Phalcon\Mvc\View();
echo $view->render('posts', 'show', $params);
// Phalcon\Mvc\View\Simple
$simpleView = new \Phalcon\Mvc\View\Simple();
echo $simpleView->render('posts/show', $params);
Using Partials
--------------
Partial templates are another way of breaking the rendering process into simpler more manageable chunks that can be reused by different
Expand Down
26 changes: 26 additions & 0 deletions fr/reference/micro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,32 @@ Rendering Views
});
Please note that this code block uses :doc:`Phalcon\\Mvc\\View\\Simple <../api/Phalcon_Mvc_View_Simple>` which uses relative paths instead of controllers and actions.
If you would like to use :doc:`Phalcon\\Mvc\\View\\Simple <../api/Phalcon_Mvc_View_Simple>` instead, you will need to change the parameters of the :code:`render()` method:

.. code-block:: php
<?php
$app = new Phalcon\Mvc\Micro();
$app['view'] = function () {
$view = new \Phalcon\Mvc\View();
$view->setViewsDir('app/views/');
return $view;
};
// Return a rendered view
$app->get('/products/show', function () use ($app) {
// Render app/views/products/show.phtml passing some variables
echo $app['view']->render('products', 'show', array(
'id' => 100,
'name' => 'Artichoke'
));
});
Error Handling
--------------
A proper response can be generated if an exception is raised in a micro handler:
Expand Down
16 changes: 16 additions & 0 deletions fr/reference/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,22 @@ To render a view it's necessary to call the render method explicitly indicating
}
}
This is different to :doc:`Phalcon\\Mvc\\View <../api/Phalcon_Mvc_View>` who's :code:`render()` method uses controllers and actions as parameters:

.. code-block:: php
<?php
$params = array('posts' => Posts::find());
// Phalcon\Mvc\View
$view = new \Phalcon\Mvc\View();
echo $view->render('posts', 'show', $params);
// Phalcon\Mvc\View\Simple
$simpleView = new \Phalcon\Mvc\View\Simple();
echo $simpleView->render('posts/show', $params);
Using Partials
--------------
Partial templates are another way of breaking the rendering process into simpler more manageable chunks that can be reused by different
Expand Down
26 changes: 26 additions & 0 deletions ja/reference/micro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,32 @@ Micro\\MVCを使用した中規模アプリケーションでは、コントロ
});
Please note that this code block uses :doc:`Phalcon\\Mvc\\View\\Simple <../api/Phalcon_Mvc_View_Simple>` which uses relative paths instead of controllers and actions.
If you would like to use :doc:`Phalcon\\Mvc\\View\\Simple <../api/Phalcon_Mvc_View_Simple>` instead, you will need to change the parameters of the :code:`render()` method:

.. code-block:: php
<?php
$app = new Phalcon\Mvc\Micro();
$app['view'] = function () {
$view = new \Phalcon\Mvc\View();
$view->setViewsDir('app/views/');
return $view;
};
// Return a rendered view
$app->get('/products/show', function () use ($app) {
// Render app/views/products/show.phtml passing some variables
echo $app['view']->render('products', 'show', array(
'id' => 100,
'name' => 'Artichoke'
));
});
Error Handling
--------------
A proper response can be generated if an exception is raised in a micro handler:
Expand Down
16 changes: 16 additions & 0 deletions ja/reference/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,22 @@ To render a view it's necessary to call the render method explicitly indicating
}
}
This is different to :doc:`Phalcon\\Mvc\\View <../api/Phalcon_Mvc_View>` who's :code:`render()` method uses controllers and actions as parameters:

.. code-block:: php
<?php
$params = array('posts' => Posts::find());
// Phalcon\Mvc\View
$view = new \Phalcon\Mvc\View();
echo $view->render('posts', 'show', $params);
// Phalcon\Mvc\View\Simple
$simpleView = new \Phalcon\Mvc\View\Simple();
echo $simpleView->render('posts/show', $params);
パーシャルの使用
--------------
Partial templates are another way of breaking the rendering process into simpler more manageable chunks that can be reused by different
Expand Down
26 changes: 26 additions & 0 deletions pl/reference/micro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,32 @@ Rendering Views
});
Please note that this code block uses :doc:`Phalcon\\Mvc\\View\\Simple <../api/Phalcon_Mvc_View_Simple>` which uses relative paths instead of controllers and actions.
If you would like to use :doc:`Phalcon\\Mvc\\View\\Simple <../api/Phalcon_Mvc_View_Simple>` instead, you will need to change the parameters of the :code:`render()` method:

.. code-block:: php
<?php
$app = new Phalcon\Mvc\Micro();
$app['view'] = function () {
$view = new \Phalcon\Mvc\View();
$view->setViewsDir('app/views/');
return $view;
};
// Return a rendered view
$app->get('/products/show', function () use ($app) {
// Render app/views/products/show.phtml passing some variables
echo $app['view']->render('products', 'show', array(
'id' => 100,
'name' => 'Artichoke'
));
});
Error Handling
--------------
A proper response can be generated if an exception is raised in a micro handler:
Expand Down
16 changes: 16 additions & 0 deletions pl/reference/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,22 @@ To render a view it's necessary to call the render method explicitly indicating
}
}
This is different to :doc:`Phalcon\\Mvc\\View <../api/Phalcon_Mvc_View>` who's :code:`render()` method uses controllers and actions as parameters:

.. code-block:: php
<?php
$params = array('posts' => Posts::find());
// Phalcon\Mvc\View
$view = new \Phalcon\Mvc\View();
echo $view->render('posts', 'show', $params);
// Phalcon\Mvc\View\Simple
$simpleView = new \Phalcon\Mvc\View\Simple();
echo $simpleView->render('posts/show', $params);
Using Partials
--------------
Partial templates are another way of breaking the rendering process into simpler more manageable chunks that can be reused by different
Expand Down
26 changes: 26 additions & 0 deletions pt/reference/micro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,32 @@ Rendering Views
});
Please note that this code block uses :doc:`Phalcon\\Mvc\\View\\Simple <../api/Phalcon_Mvc_View_Simple>` which uses relative paths instead of controllers and actions.
If you would like to use :doc:`Phalcon\\Mvc\\View\\Simple <../api/Phalcon_Mvc_View_Simple>` instead, you will need to change the parameters of the :code:`render()` method:

.. code-block:: php
<?php
$app = new Phalcon\Mvc\Micro();
$app['view'] = function () {
$view = new \Phalcon\Mvc\View();
$view->setViewsDir('app/views/');
return $view;
};
// Return a rendered view
$app->get('/products/show', function () use ($app) {
// Render app/views/products/show.phtml passing some variables
echo $app['view']->render('products', 'show', array(
'id' => 100,
'name' => 'Artichoke'
));
});
Error Handling
--------------
A proper response can be generated if an exception is raised in a micro handler:
Expand Down
16 changes: 16 additions & 0 deletions pt/reference/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,22 @@ To render a view it's necessary to call the render method explicitly indicating
}
}
This is different to :doc:`Phalcon\\Mvc\\View <../api/Phalcon_Mvc_View>` who's :code:`render()` method uses controllers and actions as parameters:

.. code-block:: php
<?php
$params = array('posts' => Posts::find());
// Phalcon\Mvc\View
$view = new \Phalcon\Mvc\View();
echo $view->render('posts', 'show', $params);
// Phalcon\Mvc\View\Simple
$simpleView = new \Phalcon\Mvc\View\Simple();
echo $simpleView->render('posts/show', $params);
Using Partials
--------------
Partial templates are another way of breaking the rendering process into simpler more manageable chunks that can be reused by different
Expand Down
26 changes: 26 additions & 0 deletions ru/reference/micro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,32 @@ To access the HTTP method data `$app` needs to be passed into the closure:
});
Please note that this code block uses :doc:`Phalcon\\Mvc\\View\\Simple <../api/Phalcon_Mvc_View_Simple>` which uses relative paths instead of controllers and actions.
If you would like to use :doc:`Phalcon\\Mvc\\View\\Simple <../api/Phalcon_Mvc_View_Simple>` instead, you will need to change the parameters of the :code:`render()` method:

.. code-block:: php
<?php
$app = new Phalcon\Mvc\Micro();
$app['view'] = function () {
$view = new \Phalcon\Mvc\View();
$view->setViewsDir('app/views/');
return $view;
};
// Return a rendered view
$app->get('/products/show', function () use ($app) {
// Render app/views/products/show.phtml passing some variables
echo $app['view']->render('products', 'show', array(
'id' => 100,
'name' => 'Artichoke'
));
});
Error Handling
--------------
A proper response can be generated if an exception is raised in a micro handler:
Expand Down
16 changes: 16 additions & 0 deletions ru/reference/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,22 @@ If we had used :code:`$this->view->setTemplateBefore('common')`, this would be t
}
}
This is different to :doc:`Phalcon\\Mvc\\View <../api/Phalcon_Mvc_View>` who's :code:`render()` method uses controllers and actions as parameters:

.. code-block:: php
<?php
$params = array('posts' => Posts::find());
// Phalcon\Mvc\View
$view = new \Phalcon\Mvc\View();
echo $view->render('posts', 'show', $params);
// Phalcon\Mvc\View\Simple
$simpleView = new \Phalcon\Mvc\View\Simple();
echo $simpleView->render('posts/show', $params);
Части шаблонов (Partials)
-------------------------
Части шаблонов (Partial templates) — это ещё один способ дробления процесса отрисовки на более простые части, которые впоследствии могут быть использованы в различных частях приложения. С помощью них можно вынести код отрисовки какой-то конкретной части шаблона в отдельный файл.
Expand Down

0 comments on commit 1381b41

Please sign in to comment.