- Where Developers Learn, Share, & Build Careers


question

How to appear on each page is a widget (database call) Can I apply to the website?

Context

I have a traditional web application with sidebar. The sidebar includes data:

  • Username,
  • Details about the account (last connection and others)
  • Demographic message users by profile
  • And other data extracted from the database.

So far the solution

As it is shown in the official document, it is possible to present a template inside a template which is an interesting feature but it is not enough Since I need data from the database to be sung in my widget, I

This will mean:

  1. Obtaining all the data needed for the sidebar anywhere < / Li>
  2. From each controller, each view of that data Passing switch to
  3. Calls to an external template for each template at the end, with the data.

What I would like to do as I am present in the Symfony2 framework I want to be able to call the controller directly.

  {% myController: MyActionMethod%}  

How can this kind of mechanism be implemented?

PS: Yes, I have searched around for a while. This question got "the same question":

There are two solutions, as you've mentioned before - it is going through the data controller as an object type and then using tags to change it Are there.

The second solution is reverse, as each template is just one Scala function, you can also call some method in your controller, which will get the required data and subtitle Will present.

Meaning To reach controllers. Using myController.myMethod (integer one, integer b) template

  & lt; Div & gt; @MicTontroller.I method (1,2) & lt; / Div & gt;  


Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -