2012-04-23 101 views
0

你能帮助我在此:无效的XML标记语法追加

class Custom_View_Helper_AddThis extends Zend_View_Helper_Abstract 
{ 

    static $instances = 0; 

    /** 
    * @var Zend_View_Interface 
    */ 
    public $view; 

    /** 
    * Return AddThis social sharin toolkit 
    * @param $url uri of page to share 
    * @param $title title of page 
    * @param $anews render social addthis at the end of the news 
    * @return void 
    */ 
    public function addThis($url = null, $title = null, $anews = false) { 
     $domain = 'http://' . $_SERVER['HTTP_HOST'] . '/'; 
     $link = $domain . $url; 
     $html = <<<EOT 
     <!-- AddThis Button BEGIN --> 
     <div class="addthis_toolbox addthis_default_style" addthis:url="$link" addthis:title="$title"> 
     <a class="addthis_button_linkedin_counter"></a> 
     </div> 
     <!-- AddThis Button END --> 
EOT; 
     $html2 = sprintf(' 
     <div class="addthis_toolbox addthis_default_style" addthis:url="%s" addthis:title="%s"> 
     <a class="vl addthis_button_google_plusone" g:plusone:size="tall"></a> 
     </div>', $link, $title); 

     $tracking = " 
     var addthis_config = { 
      data_ga_property: 'UA-XXXXXXXX-X', 
      data_ga_social: true 
     };" . PHP_EOL; 

     $src = "//s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f94ba586f83fcc8"; 
     self::$instances += 1; 
     $mscript = $this->view->HeadScript(); 
     if (self::$instances == 1) { 
      $mscript->appendScript($tracking); 
      if ($anews) { 
       $mscript->appendScript(' 
       $(document).ready(function(){ 
        $("#social_link").append('. $html2 .'); 
       }); 
       '); 
      } 
      $mscript->appendFile($src); 
     } 
     return $html; 
    } 

    /** 
    * Sets the view field 
    * @param $view Zend_View_Interface 
    */ 
    public function setView(Zend_View_Interface $view) { 
     $this->view = $view; 
    } 
} 

我想创建一个Zend项目将产生社会共享插件视图助手。

我得到的第一个图标和链接设置正确,但发送到jQuery函数不起作用,我在萤火虫控制台中得到无效的XML标签语法。我一遍又一遍地尝试,似乎没有任何工作。

这里的JavaScript生成

$(document).ready(function(){ 
$("#social_link").html(
<div class="addthis_toolbox addthis_default_style" addthis:url="http://ayaou//news/bonjour-ayaou" addthis:title="Bonjour Ayaou"> 
<a class="vl addthis_button_tweet" tw:count="vertical"></a> 
<a class="vl addthis_button_google_plusone" g:plusone:size="tall"></a> 
<a class="addthis_button_facebook_like" fb:like:layout="button_count" 
fb:like:action="recommend"></a> 
<a class="addthis_button_facebook_send"></a> 
</div>); 
}); 
+0

无效的xml在哪里? – jrummell 2012-04-23 16:44:43

+0

确定我粘贴助手生成的代码 无效的XML标记语法 [塞河畔UNE ERREUR] \t 这点上** G:Plusone精选... ** – 2012-04-23 18:19:03

+0

我不认为'G:Plusone精选: size =“tall”'是有效的html。您是否尝试过使用AddThis脚本的XHTML兼容版本? – jrummell 2012-04-23 18:26:34

回答

0

好吧,我改变了我的代码,简单的和重复的HTML代码。