Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How can I get data from one entity and show it on every page?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tetranz  
View profile  
 More options Sep 12 2012, 10:44 pm
From: Tetranz <tetr...@gmail.com>
Date: Wed, 12 Sep 2012 19:44:03 -0700 (PDT)
Local: Wed, Sep 12 2012 10:44 pm
Subject: How can I get data from one entity and show it on every page?

What's the best and most efficient way to get some data from one entity and
display it on every page? I'm using twig and doctrine.

I have an entity and database table which is only ever going to have one
instance. It has things like company name etc. It's essentially
configuration stuff so I know a config file is more efficient but I want it
to be editable by an admin user.

I guess I'm asking two questions. Where do I put the code to retrieve the
entity on every request and how do I get the data into my top level twig
template?

Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christian Flothmann  
View profile  
 More options Sep 13 2012, 9:08 am
From: Christian Flothmann <christian.flothm...@xabbuh.de>
Date: Thu, 13 Sep 2012 15:07:24 +0200
Local: Thurs, Sep 13 2012 9:07 am
Subject: Re: [Symfony2] How can I get data from one entity and show it on every page?
Hi,

> I guess I'm asking two questions. Where do I put the code to retrieve the
> entity on every request and how do I get the data into my top level twig
> template?

I'm not quite sure if this is best practive but I suppose writing a Twig
extension as mentioned under [1] could be appropriate to achieve this.

Regards,
Christian

[1]
http://symfony.com/doc/master/cookbook/templating/global_variables.ht...
complex-global-variables


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jB!nfo  
View profile  
 More options Sep 14 2012, 11:07 am
From: jB!nfo <baazzilhas...@gmail.com>
Date: Fri, 14 Sep 2012 08:07:28 -0700 (PDT)
Local: Fri, Sep 14 2012 11:07 am
Subject: Re: How can I get data from one entity and show it on every page?

Hi

create a listener that execute on every request, put the data in the
session, and check if the data exist in the session, if yes then dont do a
query to database, else load data from database.
I think in session is better, if u want to get theme in Twig:
app.session.get('param_name')

regards

Le jeudi 13 septembre 2012 02:44:03 UTC, Tetranz a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Cambridge  
View profile  
 More options Sep 14 2012, 11:57 am
From: Robert Cambridge <rob...@boxlightmedia.com>
Date: Fri, 14 Sep 2012 08:57:40 -0700 (PDT)
Local: Fri, Sep 14 2012 11:57 am
Subject: Re: How can I get data from one entity and show it on every page?

Hi Tetranz

1. Create a service which supplies the entity
http://symfony.com/doc/current/book/service_container.html
2. Set a global twig variable which exposes that service to
twig http://symfony.com/doc/2.0/cookbook/templating/global_variables.html

Hope this helps
Rob


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »