Jump to content

Suppression du formatage du texte suite à un import


luci1

Recommended Posts

Bonjour à tous,

 

Voici une petite astuce pour supprimer le formatage d'une description de produit ajouté manuellement par un webmaster :

 

class Product extends ProductCore
{
public function __construct($id_product = NULL, $full = false, $id_lang = NULL)
{
  parent::__construct($id_product, $full, $id_lang);
  if (  ! is_array( $this->description ) )
  {  
   $this->description = preg_replace( array('#<span style="(?:[[:alnum:]\-,]*\s*:\s*[[:alnum:]\-,]*;\s*)*">#u','#</span>#'), array('',''), $this->description );
  }
  else{
   $this->description = array_map( function($val){return preg_replace( array('#<span style="(?:[[:alnum:]\-,]*\s*:\s*[[:alnum:]\-,]*;\s*)*">#u','#</span>#'), array('',''), $val );}, $this->description);
  }
}
}

 

Ici, on surcharge la fonction __construct de la classe Product.php (/override/classes/Product.php) et on enlève toutes les balises span qui sont dans le texte.

 

En espérant que ça puisse servir.

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...