Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8353599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:18:43+00:00 2026-06-09T09:18:43+00:00

I have created two functions in controller of Symfony as follow: first is newAction

  • 0

I have created two functions in controller of Symfony as follow:

first is newAction

public function newAction()
{
    return $this->render('AcmeTaskBundle:Default:index.html.twig');
}

then subAction

public function subAction()
{
    echo "hello";
}

I want to use some data from index.html.twig into subAction function.

How I can do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:18:45+00:00Added an answer on June 9, 2026 at 9:18 am

    All you need is to use

    $content = $this->renderView('AcmeTaskBundle:Default:index.html.twig')
    

    This will render contents of template in variable

    http://symfony.com/doc/current/book/controller.html#rendering-templates

    EDIT according to comment

    If you need to render only part of template – then you should refactor your templates.

    Exclude that part of code from your index.html.twig into separate template file and include it in index.html.twig:

    ...
    {% include 'AcmeTaskBundle:Default:subpage.html.twig' %}
    ...
    

    And then in your subAction() call:

        $content = $this->renderView('AcmeTaskBundle:Default:subpage.html.twig')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following two actions in my controller: function add() { if (!empty($this->data))
I have created two functions that sum and subtract the numeric values of two
I have created two imageViews promatically as shown below: public void createImageViews(Integer count){ ImageView[]
In my controller I have two functions that pull all records from the db
I have a function that creates time intervals between two time marks. The function
I have a problem to create a preprocessor macro function, that concatenates two Strings
I have created two WindowSurface (WPF), and I want to navigate betwen them. I've
I have created two tables & inserted values as shown below . Table 1
I have created two Pages Page1.xaml and Page2.xaml in windows8 metro apps. I have
I have created two DbContexts, one is for application configuration, the second is for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.