javascript - Placeholders in Phalcon -


I am used for ASP.NET MVC, where I can define a section in the razor scene: / p>

  @ html.RenderSection ("script")   

I usually put it at the bottom of my layout view. Thus, I can add scripts to my thoughts in this way and under the body, where the script section is defined, it will be included:

  @section scripts {& lt; Script & gt; (Function () {// do stuff ...} ()); & Lt; / Script & gt; }   

In the Falcon, I can put it in the bottom of my layout view:

  $ this-> assets-> outputJs ();   

Then I can add script to my thoughts like this:

  $ this-> assets-> AddJs ('js / whatever.js');   

The only downside of this method is the script for this view in a separate file, which means a different request. I would like to add the script directly to the scene, as I can with the razor and still have it provided in the lower part of the body. Does the Falcon allow you to do this?

Yes, you can use it:

  & lt ;; Php $ this- & gt; Partial ("partial / js / whatever")? & Gt;   

Where js / whatever a php template in a views / partials / js / whatever.phtml The file is

Apart from this, you can use the template engine and do the same:

  {{partial ('partial / js / jo')}}   

or use it includes:

  {% include "partials / js / whatever"%}   

in vault you [Blocks] [3] can also be used where you can main parts of the main layout (like footer ) in the template file Defined micro and each visual file you can define that should do it.

  {# templates / base .volt #} & lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; My page & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div id = "content" & gt; {% Block content%} {% endblock%} & lt; / Div & gt; & Lt; Div id = "footer" & gt; {% Block footer} {% endblock%} & lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

and in the view:

  {% "templates / base.value"%} extends {% block content%} & lt; H1 & gt; My page & lt; / H1> {% Endblock%} {% block footer%} {{partial ('partial / js / joe')}} {% endblock%}   

I wrote that the volt is for template Engine for the Falcon, but if you are using plain PPL then I do not know the exact solution. You can create simple service which collects links of templates in the controller and then output them partially in the main template.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -