2011-05-26 81 views
1

hello在那里我必须实现一个jQuery的任务到Nextgen Gallery Slider Widget PHP输出之一。至少我认识到我因为我的经历而陷入了无处不在的境地。有没有人可以帮助我呢?将Javascript插入到PHP表格

$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

为什么JS之间的PHP?请写在页面的顶部或底部 – diEcho 2011-05-26 10:31:57

+0

请你提一下这样做的动机是什么?你想要使用PHP动态插入JS? – 2011-05-26 10:35:50

+0

就我所见,我必须直接在输出中写入该命令,以便处理整个嵌套。在页面的顶部或底部,我到目前为止所尝试的,浏览器不理解点击功能,并且不要让div再点击一次。因为没有循环,这就是我认为 – 2011-05-26 10:40:33

回答

0

你可以实现你想要使用PHP定界符功能的东西,这里是a simple tutorial on heredoc and its usage 选中此项。你只需要用你的JS代码来替换消息。你完成了。

+0

不能处理这个......但谢谢你们。 – 2011-05-26 15:48:56

+0

您面临的问题是什么? – 2011-05-26 15:51:07