2017-03-03 109 views
0

我創建了一個簡單的代碼html,爲了在我的電子商務產品的描述中使用premashover,我使用prestashop,但是當我粘貼並保存此代碼時,prestashop會發生變化並跳過很多標籤..這是HTML,我創建:標籤html onmouseover for prestashop

<!doctype html> 
 
<html> 
 
<head> 
 
\t <title></title> 
 
</head> 
 
<body> 
 
<center> 
 
<div id="sx">&nbsp; 
 
<center> 
 
<div id="wrapper"> 
 
<center> 
 
<div id="content"> 
 
<center><br /> 
 
<br /> 
 
&nbsp; 
 
<table align="center" border="0" width="700"> 
 
\t <tbody> 
 
\t \t <tr> 
 
\t \t \t <td align="center" rowspan="2" style="width: 20%; background-color: rgb(0, 0, 0);"><font color="#000000" face="Verdana" size="3"><img alt="Joomoda" onmouseover="document.mainpic.src='https://dstreet.pl/data/gfx/pictures/large/1/8/681_7.jpg'" src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_7.jpg 
 
" style="border: 1px solid rgb(68, 68, 68); width: 155px; height: 200px;" /> <img alt="Joomoda" onmouseover="document.mainpic.src='https://dstreet.pl/data/gfx/pictures/large/1/8/681_1.jpg'" src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_1.jpg 
 
" style="border: 1px solid rgb(68, 68, 68); width: 155px; height: 200px;" /><img alt="Joomoda" onmouseover="document.mainpic.src='https://dstreet.pl/data/gfx/pictures/large/1/8/681_5.jpg'" src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_5.jpg 
 
" style="border: 1px solid rgb(68, 68, 68); width: 155px; height: 200px;" /> </font></td> 
 
\t \t \t <td align="center" rowspan="2" style="width: 20%; background-color: rgb(0, 0, 0);"><img alt="Joomoda" onmouseover="document.mainpic.src='https://dstreet.pl/data/gfx/pictures/large/1/8/681_4.jpg'" src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_4.jpg 
 
" style="font-family: Verdana; border: 1px solid rgb(68, 68, 68); width: 155px; height: 200px;" /><img alt="Joomoda" onmouseover="document.mainpic.src='https://dstreet.pl/data/gfx/pictures/large/1/8/681_3.jpg'" src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_3.jpg 
 
" style="font-family: Verdana; border: 1px solid rgb(68, 68, 68); width: 155px; height: 200px;" /><img alt="Joomoda" onmouseover="document.mainpic.src='https://dstreet.pl/data/gfx/pictures/large/1/8/681_2.jpg'" src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_2.jpg 
 
" style="font-family: Verdana; border: 1px solid rgb(68, 68, 68); width: 155px; height: 200px;" /></td> 
 
\t \t \t <td align="center" style="background-color: rgb(0, 0, 0);"><font color="#000000" face="Verdana" size="3"><img align="absmiddle" name="mainpic" src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_7.jpg" style="max-height: 612px; border-width: 4px; border-style: solid; margin: 2px; width: 435px; height: 560px;" /></font></td> 
 
\t \t </tr> 
 
\t \t <tr> 
 
\t \t \t <td align="center" style="background-color: rgb(255, 255, 255); height: 40px; border-color: rgb(0, 0, 0); vertical-align: middle;"><span style="font-size:26px;"><strong>FELPA UOMO BX0060</strong></span></td> 
 
\t \t </tr> 
 
\t </tbody> 
 
</table> 
 
</center> 
 
</div> 
 
</center> 
 
</div> 
 
</center> 
 
</div> 
 
</center> 
 
</body> 
 
</html>

,這是HTML代碼返回我的PrestaShop當我保存:

<table align="center" border="0" style="width: 700px;" class=" cke_show_border"> 
 
<tbody> 
 
<tr> 
 
<td rowspan="2" style="background-color: #000000; width: 20%;"><img alt="Joomoda" data-cke-saved-src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_7.jpg 
 
" src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_7.jpg 
 
" style="border: 1px solid #444444; height: 200px; width: 155px;" /> <img alt="Joomoda" data-cke-saved-src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_1.jpg 
 
" src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_1.jpg 
 
" style="border: 1px solid #444444; height: 200px; width: 155px;" /><img alt="Joomoda" data-cke-saved-src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_5.jpg 
 
" src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_5.jpg 
 
" style="border: 1px solid #444444; height: 200px; width: 155px;" /></td> 
 
<td rowspan="2" style="background-color: #000000; width: 20%;"><img alt="Joomoda" data-cke-saved-src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_4.jpg 
 
" src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_4.jpg 
 
" style="border: 1px solid #444444; font-family: verdana; height: 200px; width: 155px;" /><img alt="Joomoda" data-cke-saved-src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_3.jpg 
 
" src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_3.jpg 
 
" style="border: 1px solid #444444; font-family: verdana; height: 200px; width: 155px;" /><img alt="Joomoda" data-cke-saved-src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_2.jpg 
 
" src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_2.jpg 
 
" style="border: 1px solid #444444; font-family: verdana; height: 200px; width: 155px;" /></td> 
 
<td style="background-color: #000000;"><img data-cke-saved-src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_7.jpg" src="https://dstreet.pl/data/gfx/pictures/large/1/8/681_7.jpg" style="border-style: solid; border-width: 4px; height: 560px; margin: 2px; max-height: 612px; width: 435px;" /></td> 
 
</tr> 
 
<tr> 
 
<td style="background-color: #ffffff; border-color: #000000; height: 40px; vertical-align: middle;"><span style="font-size: 26px;"><strong>FELPA UOMO BX0060</strong></span></td> 
 
</tr> 
 
</tbody> 
 
</table>

可以幫助我請創建一個類似的代碼,這將與prestashop兼容嗎?

Thans

安德烈

+0

你要在哪裏「保存」這個? – sadlyblue

+0

在prestashop產品的描述 – Andrea

+0

這裏你可以看到結果 [鏈接](http://www.joomoda.com/felpe-uomo/1591-felpa-uomo-djm681.html) – Andrea

回答

0

你需要關閉HTML淨化器菜單中的選項 - >常規。 這隻會阻止刪除一些代碼,但它仍然不會接受在該域中的onmouseover。爲了達到這個目的,最好的方法是在類Validate中重寫isCleanHtml函數。創建文件覆蓋/班/ Validate.php與此內容:

<?php 
class Validate extends ValidateCore 
{ 
    public static function isCleanHtml($html, $allow_iframe = false) 
    { 
     $events = 'onmousedown|onmousemove|onmmouseup|onmouseout|onload|onunload|onfocus|onblur|onchange'; 
     $events .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend'; 
     $events .= '|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onmove'; 
     $events .= '|onbounce|oncellchange|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondeactivate|ondrag|ondragend|ondragenter|onmousewheel'; 
     $events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart'; 
     $events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange'; 
     $events .= '|onselectstart|onstart|onstop'; 

     if (preg_match('/<[\s]*script/ims', $html) || preg_match('/('.$events.')[\s]*=/ims', $html) || preg_match('/.*script\:/ims', $html)) { 
      return false; 
     } 

     if (!$allow_iframe && preg_match('/<[\s]*(i?frame|form|input|embed|object)/ims', $html)) { 
      return false; 
     } 

     return true; 
    } 
} 

然後刪除文件緩存/ class_index.php。並嘗試再次保存。

此功能內容將阻止與以前相同的代碼,除非現在不會搜索onmouseover。

+0

嗨,謝謝你的幫助,我創建了文件php和我刪除了文件緩存/override/classes/cache/index.php, 第一次嘗試,他告訴我說明的內容無效,之後我試圖再次保存,但現在,當我保存,直接刪除創建的html代碼,只保留用普通編輯器創建的初始部分。 有什麼想法? – Andrea