将Javascript插入PHP表

时间:2011-05-26 10:28:45

标签: php javascript

你好我必须在其中一个Nextgen Gallery Slider Widget PHP输出中实现一个jquery任务。至少我认识到我陷入了无处不在的境地,因为我的经历。是否有人可以帮助我?

$output .= "\n<script type=\"text/javascript\">";
$output .= "\n  jQuery(window).load(function() {";                
// Shuffle results on random order so even if page is cached the order will be different each time
if($order == 'random' && $shuffle == 'true')
{
  $output .= "\n    jQuery('div#" . $html_id . "').jj_ngg_shuffle();";
}
$output .= "\n    jQuery('div#" . $html_id . "').nivoSlider(";
if(count($javascript_args) > 0)
{
  $output .= "{" . implode(",", $javascript_args) . "}";
}
$output .= ");";
if($has_control_nav && $has_thumbs)
{
  if($controlnavthumbs == 'nextgen_thumbs' || $controlnavthumbs == 'nextgen_original')
  {
    $output .= "\n    JJNGGUtils.wordpressThumbs('" . $html_id . "', " . ($controlnavthumbs == 'nextgen_thumbs' ? 'true' : 'false') . ");";
  }
  if($has_center && $thumbsgap != '')
  {
    $output .= "\n    JJNGGUtils.wordpressThumbsCenterFix('" . $html_id . "');";
  }
  $output .= "\n    jQuery('div#" . $html_id . " div.nivo-controlNav').css('visibility', 'visible');";
}
$output .= "\n  });";  
$output .= "\n</script>\n";

if($shortcode != '1')
{
  echo $before_widget . "\n<ul class=\"ul_jj_slider\">\n    <li class=\"li_jj_slider\">" . $output . "\n    </li>\n  </ul>\n" . $after_widget;     
}
else
{
  echo $output;
}

}

id喜欢添加

    <script type="text/javascript">
jQuery(document).ready(function() {
 // hides the slickbox as soon as the DOM is ready
  jQuery('#slider').css({visibility: "hidden"});

 // toggles the slickbox on clicking the noted link
  jQuery('a.nivo-controlNav').click(function() {
    jQuery('#slider').css({visibility: "visibile"});
    return false;
  });
});
</script>

非常感谢任何提示和帮助

1 个答案:

答案 0 :(得分:0)

您可以使用PHP Heredoc功能实现您想要的功能,这里是simple tutorial on heredoc and its usage 检查一下。您只需要用JS代码替换消息。你完成了。