Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How do I get around htmlEscape
 
Brent W Peterson
Moderator
 
Avatar
Total Posts:  3217
Joined:  2009-02-26
Minneapolis MN
 

I have a function I created to list the categories on a page

<?php if (!Mage::registry('current_category')) return ?>
<?php  $_helper    
$this->helper('catalog/output'); ?>
<?php $_categories
=$this->getCurrentChildCategories() ?>
<?php 
if($_categories->count()): ?>

                  
<table border="0" width="525">
                    
<?php foreach ($_categories as $_category): ?>
                        <?php 
if($_category->getIsActive()): ?>
                      
<tr><td width="90" valign="top">    
                    
<?php if(!strlen($_category->getImageUrl()) < 5): ?>
                    
<img src="<?php echo $this->htmlEscape($_category->getImageUrl()) ?>" align="center" width="90" />
                    
<?php endif;  ?>
                    
                    
</td><td>                
                            <
h2><a href="<?php echo $this->getCategoryUrl($_category) ?>"<?php if ($this->isCategoryActive($_category)): ?> class="active"<?php endif ?>>
                            
<?php echo $this->htmlEscape($_category->getName()) ?></a></h2>            
                        
<?php echo $this->htmlEscape($_category->getDescription()) ?>
                    
                        
</td></tr>
                        
                        
<?php endif; ?>
                    <?php 
endforeach; ?>
                   
</table>
              
<?php endif; ?>

The problem is when I want to display my description. If I don’t use the htmlEscape, the description will not show up. When I use htmlEscape the embedded HTML will not work. 

Thanks,

 
Magento Community Magento Community
Magento Community
Magento Community
 
Shven
Jr. Member
 
Total Posts:  12
Joined:  2008-10-25
 

I have the same problem.

I have an attribute allowing html so people can add <br /> and <hr /> tags in the backoffice.
Isn’t there a way to allow certain tags?

 
Magento Community Magento Community
Magento Community
Magento Community
 
StephanOnline
Jr. Member
 
Total Posts:  19
Joined:  2010-02-09
Netherlands
 

try this

html_entity_decode()
 
Magento Community Magento Community
Magento Community
Magento Community
 
jazkat
Sr. Member
 
Total Posts:  154
Joined:  2009-07-09
 

Thanks Stephan!

 
Magento Community Magento Community
Magento Community
Magento Community
 
sagacity
Member
 
Total Posts:  47
Joined:  2009-12-16
 

I had problems with htmlEscape() and &. The Shop always showed it as

&amp;

html_entity_decode() helped a lot wink

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top