Skip to main content

html encode/decode in drupal

Like all major CMS drupal stores text fields in encoded html format, to prevent cross site scripting attacks. Some times drupal does not process custom fields and encoded text is displayed as it is. I come across similar issue in my current project. I also post question on StackOverflow. While search for solution I come to know about decode_entities function. decode_entities converts html encoded text to more friendly text. Similary to encode special charters in text you can use check_plain.

decode_entities function
http://api.drupal.org/api/drupal/includes!unicode.inc/function/decode_entities/7

check_plain function
http://api.drupal.org/api/drupal/includes!bootstrap.inc/function/check_plain/7

My question on StackOverflow
http://stackoverflow.com/questions/14229641/rss-feeds-view-showing-encoded-special-character-in-title

Comments

Popular posts from this blog

opensuse repair is awesome

I installed OpenSuse 11.1 on my machine. I have done kde4/kde3/gnome installation. It takes about 40-45 minutes. After instaltion I installed Nvidia driver, nvidia driver has installed new kernel (containing trace in name). When I changed boot order to make trace default kernel, grub is installed on root partition than MBR, so my system become unbootable. I got only 2 days of holidays. I come to know abt this problem after I returned to my work city (Indore) from Home (Khandwa). So I could not fix the problem. So I have to fix it via phone. My brother booted the system with Opensuse 11.1 dvd. My brother is not very technical person but he is advace-level PC user. We have never used recover/rescue installed system option. We selected automated recovery mode. It first checks all partitions and packages, all of them found is good state, setup found error boot loader configuration, we loaded boot loader configuration from disk and found that grub is installed on root partition instead of M...

Adding additional class to a button in drupal

Recently we were building a multi-domain site, we are using same theme for all sites but we want to have different colors for buttons for each domain. We achieved this using my overriding theme_button in template.php of theme, here is the snippet. /** * Overwrite theme_button() * @file template.php */ function mytheme_button($variables) { $element = $variables['element']; // Add some extra conditions to make sure we're only adding // the classto the right submit button Now add our custom class if (isset($element['#attributes'])) { $element['#attributes']['class'] [] = 'button'; $domain = domain_get_domain(); $element['#attributes']['class'] [] = $domain['machine_name']; } $variables['element'] = $element; return theme_button($variables); }

Dana Abdulrazak - most heroic runner

Only female athlete from Iraq. She is a real hero, who come from war torn country. Olympic "superlatives" to be remembered_English_Xinhua Dana Abdulrazak - most heroic runner Photo taken on Aug. 21, 2008 shows Iraqi athlete Dana Hussein Abdulrazak hold a Chinese knot in Beijing, China. Iraqi women runner Dana Abdul-Razzaq has received as loud applause as champions. The Iraqi team's only woman faced many obstacles to reach Beijing, from a sniper's bullets to a lack of training facilities and religious and cultural opposition to female athletes. Before the Olympics, she was told that Iraq was shut out of the international sports gala. When her coach consoled her by saying that she could take part in the 2012 Olympics, she broke into tears, "who knows if I could live that long!"