joomla模块include_once问题

时间:2012-06-11 12:10:17

标签: php joomla youtube include

我正在为joomla创建一个youtube播放列表模块。

如果我将模块分配给某个页面,它将在以下位置停止加载:

<div class="youtubeplayer">
    <div class="yt_holder">
            <!--Up and Down arrow -->
            <div class="you_up"><img src="modules/mod_youtube_playlist/css/up_arrow.png" alt="+ Slide" title="HIDE" /></div>
            <div class="you_down"><img src="modules/mod_youtube_playlist/css/down_arrow.png" alt="- Slide" title="SHOW" /></div>
            <!-- END  -->
        <div id="ytvideo3"></div>
            <div class="youplayer">
            <ul class="videoyou">

它似乎停止在我在下面的代码中使用'include once'的位置(下面的代码是我的模块“tmpl / default.php”文件) - 任何想法?

<?php

defined('_JEXEC') or die;

JHtml::_('behavior.framework');

JHtml::script('modules/mod_youtube_playlist/js/jquery.youtubeplaylist.js');
JHtml::script('modules/mod_youtube_playlist/js/jquery.jquery.youtubeplaylist-min.js.js');
JHtml::script('modules/mod_youtube_playlist/js/youtubeplaylist.js');
JHtml::stylesheet('modules/mod_youtube_playlist/css/youtubeplaylist.css');
JHtml::stylesheet('modules/mod_youtube_playlist/css/indext.css');
?>

<div class="youtubeplayer">
    <div class="yt_holder">
            <!--Up and Down arrow -->
            <div class="you_up"><img src="modules/mod_youtube_playlist/css/up_arrow.png" alt="+ Slide" title="HIDE" /></div>
            <div class="you_down"><img src="modules/mod_youtube_playlist/css/down_arrow.png" alt="- Slide" title="SHOW" /></div>
            <!-- END  -->
        <div id="ytvideo3"></div>
            <div class="youplayer">
            <ul class="videoyou">
            <?php
            // Use like this.
            include_once('/modules/mod_youtube_playlist/class/class.youtubelist.php');
            //in this example a playlist
            $video = new youtubelist('playlist');
            //This is the link to the playlist.
            //http://www.youtube.com/playlist?list=PLC4FBCA46405A8BF8
            //REMOVE the PL from the string if there is an PL after list=
            $video->set_playlist('<?php echo $playlist; ?>');
            $video->set_max(50);
            $video->set_order('title');
            $video->set_cachexml(false);
            $video->set_cachelife(86400);
            $video->set_xmlpath('./cache/');
            $video->set_start(1);

            if ( $video->get_videos() !=null ) {
                foreach ($video->get_videos() as $yKey => $yValue) {
                    echo '<li><p>' . $yValue['title'] . '</p><span class="time">' . $yValue['time'] . '</span><a class="videoThumb3" href="http://www.youtube.com/watch?v=' . $yValue['videoid'] . '">' . $yValue['description'] . '</a></li>';
                }
            }else{
                echo '<li>Sorry, no video\'s found</li>';
            }
            ?>
            </ul>
        </div>
    </div>
</div>

2 个答案:

答案 0 :(得分:0)

使用该路径/modules/mod_youtube_playlist/....将查找服务器的根目录,而不是您的站点根目录。

我怀疑你因为找不到而导致致命错误。

您可以使用JPATH_BASE常量,它是站点根目录的路径:

include_once(JPATH_BASE . '/modules/mod_youtube_playlist/class/class.youtubelist.php');

为了将来的调试,您应该打开错误(或查看错误日志),如果在此处发布,请始终包含完整的错误消息。

答案 1 :(得分:0)

而不是使用它:

JHtml::script('modules/mod_youtube_playlist/js/jquery.youtubeplaylist.js');
JHtml::stylesheet('modules/mod_youtube_playlist/css/indext.css');

试试这个:

$document =& JFactory::getDocument();
$document->addStyleSheet(JURI::root() . "modules/mod_youtube_playlist/css/indext.css");
$document->addScript(JURI::root() . "modules/mod_youtube_playlist/js/jquery.youtubeplaylist.js");

还建议在包含时使用ROOT而不是BASE。