我目前正在尝试修改 this 组件以使用bootstrap模式而不是自己的组件,因为组件使用的灯箱根本没有响应...而且此组件是建造......非常奇怪......
但我已经掌握了我需要做的关键文件,我只是不确定我哪里出错了。
这是变量,即模态的链接:
$link = '<a class="youModal" data-toggle="modal" href="'.JURI::base().'index.php?option=com_jusertube&view=lightbox&rid='.$video['id'].'&'.$yorvuser .'='.$youtubeuser.$doautoplay.'&eh='.$eheight.'&ew='.$ewidth.'&st='.$showtitle.'&height='.$popupy.'&width='.$popupx.'" data-target="#youModal">';
然后激活模态的JS:
jQuery(document).ready(function(){
srztb_init('a.youModal');//pass where to apply srzthickbox
imgLoader = new Image();// preload image
imgLoader.src = srztb_pathToImage;
});
function srztb_init(domChunk){
jQuery(domChunk).click(function(){
var t = this.title || this.name || null;
var a = this.href || this.alt;
var g = this.rel || false;
srztb_show(t,a,g);
this.blur();
return false;
});
}
function srztb_show(caption, url, imageGroup) {//function called when the user clicks on a srzthickbox link
jQuery('#youModal').removeData("modal");
jQuery('#youModal').modal({remote: jQuery(this).attr(url)});
}
然后是生成iframe的代码的最大块:
<?php
/**
* @package JUserTube
* @version 5.6.0
*
* @author Md. Afzal Hossain <afzal.csedu@gmail.com>
* @link http://www.srizon.com
* @copyright Copyright 2012 Md. Afzal Hossain All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
// No direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.view');
/**
* Content categories view.
*
* @package Joomla.Site
* @subpackage com_weblinks
* @since 1.5
*/
class JusertubeViewLightbox extends JViewLegacy
{
function display()
{
$filepath = dirname(__FILE__).'/../../../../modules/mod_jusertube/'.'savedxml'.'/';
if(!isset($_GET['yuser'])) $_GET['yuser'] = 0;
if(!isset($_GET['auto'])) $_GET['auto'] = 0;
$rid = $_GET['rid'];
$auto = $_GET['auto'];
if(isset($_GET['ttv'])) $ttv = $_GET['ttv'];
else $ttv = 0;
if($_GET['yuser']){
$youtubeuser = $_GET['yuser'];
$filename = $filepath.'youtube_'.$youtubeuser.'.xml';
}
else{
$youtubeuser = $_GET['vuser'];
$filename = $filepath.'vimeo_'.$youtubeuser.'.xml';
}
if($auto == 1){
$autotext = '&autoplay=1';
}
else{
$autotext = '&autoplay=0';
}
if(is_file($filename)){
$data = file_get_contents($filename);
}
$rss = new SimpleXMLElement($data);
$videos = array();
$u =& JURI::getInstance();
$url = $u->toString();
$url = str_replace("view=lightbox","view=video",$url);
$p2 = strpos($url,'&auto=');
$url = substr($url,0,$p2);
$url.='&auto=1&eh=385&ew=640&st=yes';
$url = str_replace('&','&',$url);
if($_GET['yuser']){
foreach($rss->channel->item as $item){
$guid_split = parse_url($item->link);
parse_str($guid_split['query'],$temp_v);
$tid = $temp_v['v'];
if($tid == $rid)
{
$videos['title'] = (string) $item->title;
$videos['embed'] = '<iframe class="youtube-player" type="text/html" width="'.$_GET['ew'].'" height="'.$_GET['eh'].'" src="http://www.youtube.com/embed/'.$tid.'?fs=1&rel=0'.$autotext.'" frameborder="0"></iframe>';
if($GLOBALS['pageprotocol']=='https'){
$videos['embed'] = str_replace('http:','https:',$videos['embed']);
}
break;
}
}
}
else{
foreach($rss->channel->item as $item){
$tlnk = $item->link;
if($ttv == 1){
$pos1 = strpos($tlnk,'com');
$tid = substr($tlnk,$pos1+4);
}
else{
//$pos1 = strpos($tlnk,'#');
$pos1 = strrpos($tlnk,'/');
$tid = substr($tlnk,$pos1+1);
}
if($tid == $rid)
{
str_replace('&','',$autotext);
$videos['title'] = (string) $item->title;
$videos['embed'] = '<iframe src="http://player.vimeo.com/video/'.$tid.'?'.$autotext.'" width="'.$_GET['ew'].'" height="'.$_GET['eh'].'" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
break;
}
}
}
?>
<div id="youModal" class="modal hide fade flex-video" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<h2><?php echo $videos['title']?></h2>
</div>
<div class="modal-body">
<?php echo $videos['embed'];?>
</div>
</div>
<?php
exit();
}
}
?>
抱歉,我知道最后一部分有很多代码,代码的混乱是由于我改变了组件代码,我真的希望避免重写整个组件只是为了一个模态窗口。
任何帮助都非常赞赏..
答案 0 :(得分:1)
而不是自己添加所有javascript如何在JHtml类中使用modal和renderModal函数
源代码:https://github.com/joomla/joomla-cms/blob/master/libraries/cms/html/bootstrap.php#L262
渲染模态函数位于
之下