They seem to be doing the same thing: they are passing layouts to a view.
I am new to Yii and I do not know what the difference is. Can anyone explain it?
renderPartial() - renders a named view without any layout. If you don't have any layout and want to render a named view (a view previously stored for reuse) you can use renderPartial().
beginContent() - is for managing nested layout. Inside a layout you can reuse a named view like a nested layout .
See this for a brief guide.
Related
Can I include a php file to tpl?
All I need is data from the database. I tried with required('path/file.php') but without success.
I already have controller for that. I need to include controller/file, class/php extension anything just need in tpl. I use OpenCart version 2.3.
if you need data from the database, in MVC a model should be used, and then let the controller add it's data to the $data array, which the is available to the template.
this shows how OpenCart actually works (source):
now tell me how your attempt to change a template (view) fits into there (notice the vertical lines).
just load the model into the controller and add results to $data, then it's available in the template.
You should not directly mix templates with custom PHP code, even if in some template engines it's possible.
You should rather look into means of providing your PHP logic through functions, filters or macros. This way you make your PHP code available in templates.
If OpenCart uses twig, you could look into how to do such in the documentation about extending twig here.
everyone.
I have to change the template of the FormHelper. Not for just 1 or 2 view, for ALL views. And i would like to do this without to have to write hundred of line in every view.
Is it possible to change the FormHelper default template ?
Where the default template is located ?
CakePHP documentation don't say anythings in order to change template of Whole Site, for FormHelper or Paginator, that's a real problem.
I'm not with CakePHP 3 but only CakePHP 2.6
If I understand correctly, you want to modify or use their own "bake" template, in order to avoid repetition of writing html and php code.
Here is what documentation say:
http://book.cakephp.org/2.0/en/console-and-shells/code-generation-with-bake.html#modify-default-html-produced-by-baked-templates
If you want to modify cake helper, copy from
\cakephp\lib\Cake\View\Helper
in the \cakephp\app\View\Helper
and then make modification.
Here is documentations for creating own helpers
http://book.cakephp.org/2.0/en/views/helpers.html#creating-helpers
Well...the file you are looking for is located in
/lib/Cake/View/Helper/FormHelper.php
You should search for example for:
function input(
or
function create(
that is the "template" you are looking for.
I think the easiest way to change the output is to update your $options array. There you can add classes or labels or whatever.
What is the difference between to these in cake php?
$this->fetch('title');
$this->extend('/Common/view');
$this->element('shop/cart.ctp');
fetch() is used mainly in layout file to output a block of content.
extend() is used to extend view. which allows you to wrap one view in
another.
element() is used to group an reusable piece of view.
You can learn lots from this online book/page:
http://book.cakephp.org/2.0/en/views.html
View Templates
Extending Views
Using view blocks
Displaying blocks
Using blocks for script and CSS files
Layouts
Using layouts from plugins
Elements
Passing Variables into an Element
Caching Elements
Requesting Elements from a Plugin
Creating your own view classes
View API
Hope it will help you!
I am new to Zend Framework 1 and have been working on my first project. While creating a pretty detailed view helper, I realized there is a bit of javascript (mainly ajax calls and such) that are directly related to the view helper. Currently I just have them defined in the view script that calls that helper, but I plan to move it now that I have it working correctly.
My question:
Where is the recommended place to put javascript that is directly related to a view helper?
Thanks!
Better late than never.
You should put your javascript code into the view file of the helper.
Basically if your helper is located somewhere like :
/views/helpers/YourHelper.php
You can render it in it's own view with :
return $this->view->render('-helpers/your-helper.phtml');
And put the javascript code into the helper view located at :
/views/scripts/-helpers/your-helper.phtml
Hope this will help.
Best
I started using symfony a few weeks ago, and there are some things that are not clear for me.
My question is that how could I put a list of categories (for menu) in the main layout of an application? How can I pass a variable for this layout and where to put this variable? I don't want to put it in every module.
Thanks.
Did you read about components, slots and partials? Start here: http://www.symfony-project.org/gentle-introduction/1_4/en/07-Inside-the-View-Layer#chapter_07_code_fragments
And here's the best menu plugin ever: http://www.symfony-project.org/plugins/ioMenuPlugin
You can't pass variables for the layout. Instead you can use partials or components.