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
Message from discussion View Object
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
 
Daniel Ragtek  
View profile  
 More options Oct 12 2012, 4:17 am
From: Daniel Ragtek <daniel.fat...@gmail.com>
Date: Fri, 12 Oct 2012 01:17:14 -0700 (PDT)
Local: Fri, Oct 12 2012 4:17 am
Subject: View Object

Is there another (cleaner) way to change the response depending on the
request?
I've found this codesnippet
http://stackoverflow.com/questions/12364855/how-to-render-a-view-file... which
would cause IMO too much ugly conditions in the controller actions and many
extra templates

What i want to do is to have only 2 templates

1. container /base with the header, navigation,footer, sidebars, etc..
2. content template

now, if i request : www.example.com/userinfo/1 it should return the normal
html response
if i request www.example.com/userinfo/1.json it should return the content
template, without including the container/base, but adding additional infos
to the json response

Anybody have done something similar with symfony2?
What's the best way to do this? My first idea was to create a second
container/base template for json responses and then in the content
templates to do something like

(pseudocode:)

if (isXmlHttpRequest()){
{{ extends base.html.twig}}
{else}
{{ extends base.json.twig }}

would this be a good practice or is there another, better way for this?

thx


 
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.