Jump to content

Str_replace '&', 'amp;' for validation - not translating


atwitz3nd

Recommended Posts

Hi can anyone tell me how to replace my ampersands with '&' so my page validates

here is the current output code

   $name = str_replace('.', '', strstr($categorie->name, '.'));


I tried adding this but it didn't seem to work.

      $name = str_replace('.', '', '&', '&', strstr($categorie->name, '.'));



How can i successfully translate this category name which is: fruit & veg so it validates?

Thanks very much

Link to comment
Share on other sites

Try this:


      $name = str_replace(array('.', '&'), array('', '&'), strstr($categorie->name, '.'));



Hi can anyone tell me how to replace my ampersands with '&' so my page validates

here is the current output code
   $name = str_replace('.', '', strstr($categorie->name, '.'));


I tried adding this but it didn't seem to work.

      $name = str_replace('.', '', '&', '&', strstr($categorie->name, '.'));



How can i successfully translate this category name which is: fruit & veg so it validates?

Thanks very much

Link to comment
Share on other sites

THanks for you reply. I tried your suggestion, which didn't fix it unfortunately. It didn't break it either, so I' wondering if I'm changing the right code
The output code is this:

 {$MENU} 


presumably reading from the .php file below:

>  private function getCategoryOption($id_category, $id_lang, $children = true)
 {
   $categorie = new Category($id_category, $id_lang);
   if(is_null($categorie->id))
     return;
   if(count(explode('.', $categorie->name)) > 1)
     $name = str_replace(array('.', '&'), array('', '&'), strstr($categorie->name, '.')); 
   else
     $name = $categorie->name;
   $this->_html .= ''.$name.'';
   if($children)
   {
     $childrens = Category::getChildren($id_category, $id_lang);
     if(count($childrens))
       foreach($childrens as $children)
         $this->getCategoryOption($children['id_category'], $id_lang);
   }
 }

 private function getCategory($id_category, $id_lang)
 {
   global $page_name;

   $categorie = new Category($id_category, $id_lang);
   if(is_null($categorie->id))
     return;
   $selected = ($page_name == 'category' && ((int)Tools::getValue('id_category') == $id_category)) ? ' class="sfHoverForce"' : '';
   $this->_menu .= '';
   if(count(explode('.', $categorie->name)) > 1)
     $name = str_replace(array('.', '&'), array('', '&'), strstr($categorie->name, '.')); 
   else
     $name = $categorie->name;
   $this->_menu .= 'getLink().'">'.$name.'';
   $childrens = Category::getChildren($id_category, $id_lang);
   if(count($childrens))
   {
     $this->_menu .= '</pre>
<ul>';
     foreach($childrens as $children)
       $this->getCategory($children['id_category'], $id_lang);
     $this->_menu .= '</ul>';<br>   }<br>   $this->_menu .= '';<br> 



Is this right bit, Which is affecting category and subcategory menu items
Any ideas? Thanks for your help

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...