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 9222733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:54:14+00:00 2026-06-18T03:54:14+00:00

I have the following setup: php 5.4, symfony 1.4.17, and firefox, ie, chrome. I

  • 0

I have the following setup: php 5.4, symfony 1.4.17, and firefox, ie, chrome.

I have built a simple news module.

  • table: TbNews
  • columns:
    • id as primary key
    • scontent as a text field for saving the news content. It will have html content inside, saved with CKeditor and its working perfectly.

If I use fetchOne() (in template), the html is interpreted before writting the content.

If I use symfony pager (in action, then template) the html is NOT interpreted and I see the HTML tags in the output with the content.
You can see the examples below which shows exactly what Im talking about.

I have read in other topics that for security reasons symfony output escaper automatically converts HTML into “text”, and we must use getRawValue on the data to get the original HTML chars.

  • show html tags in template – symfony and CKEDITOR. how safety?
  • Stop symfony from escaping html from query result
  • Symfony.com View Layer Output Escaping
  • Symfony sfOutputEscaper method getRawValue()

I have some questions:

  1. why symfony output escaper is working with symfony pager, and its
    not working if we use fetchOne()?
  2. how should I use getRawValue() in my example below with the symfony
    pager, interpreting the HTML and then showing only the content?
  3. Is getRawValue() the best option to get only the content written?

Example code:

//1. fetchOne() outputs content interpreting html before.
//index/templates/indexSuccess.php
//-------------------------------
$q = Doctrine_Query::create()->from('TbNews e')->where('e.id = ?', '1');
$new = $q->fetchOne(); // <p>testcontent</p>\r\n
echo $new['scontent']; 
// output:  testcontent  --- OK, output is not escaped because we are jumping symfony output escaper since we are doing it directly in the action.


//2. Get all news with symfony pager, html tags are not interpreted, html tags are shown.
//index/actions/actions.class.php
//-------------------------------
$app_max_news_in_homepage = 4;
$this->pager = new sfDoctrinePager('TbNews', $app_max_news_in_homepage);
$this->pager->setQuery(Doctrine::getTable('TbNews')->createQuery('a'));
$this->pager->setPage($request->getParameter('page', 1));
$this->pager->init();

//index/templates/indexSuccess.php 
//--------------------------------
foreach ($pager->getResults() as $new)
{
  echo $new['scontent']; // &lt;p&gt;testcontent&lt;/p&gt;\r\n
}

//output:  <p>testcontent</p>  --- OK, since output is escaped by symfony output escaper since we get data at the action and show it in the template.
  • 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-18T03:54:15+00:00Added an answer on June 18, 2026 at 3:54 am

    Your first test is wrong.

    When you test with fetchOne(), you are inside an action. So the content you retrieve from your database and the one you displayed (with echo) isn’t escaped because it’s not send to the template.

    When you perform your second test, you retrieve the content from the action and display the result inside the template. In this case, the content is escaped by sfOutputEscaper. If you make the first test and then try to display the content in your template, you’ll see that the html is escaped.

    // in actions
    $this->new = $q->fetchOne();
    
    // in template
    echo $new['scontent'];
    
    // result-> &lt;p&gt;testcontent&lt;/p&gt;\r\n
    

    If you have activated escaping_strategy & escaping_method inside your apps/[app_name]/config/settings.yml, every thing that will be given to the template will be escaped.

    When I want to display a html content which has been escaped, I usually use the unescape method from the sfOutputEscaper. In your case:

    foreach ($pager->getResults() as $new)
    {
      echo sfOutputEscaper::unescape($new['scontent']);
    }
    

    another option (said by Michal Trojanowski):

    foreach ($pager->getResults()->getRawValue() as $new)
    {
      echo $new['scontent'];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following setup: Table: Question QuestionId Table: QuestionTag QuestionId TagId Table: Tag
I have following setup. index.php require_once common.php; ... common.php ... $obj = new MyClass;
I have the following setup in MySQL: Table Game : gameid , p1state ,
I have the following setup for phpmyadmin: <Directory /usr/share/phpmyadmin> Options FollowSymLinks DirectoryIndex index.php Order
I have the following setup: class.staff.php This defines many variables, the one I'm working
I have the following setup: NGINX -> Apache -> PHP scripts Apache is serving
I have the following: <?php #Load in File $xmlUrl =http://sports.espn.go.com/espn/rss/mlb/news; $ConvertToXml = simplexml_load_file($xmlUrl); #
I have the following setup: An endless running PHP process that looks at a
How do you setup a multi-developer XDebug PHP environment? I have the following setup:
I currently have the following setup in my module. public function onBootstrap( EventInterface $e

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.