我已经有一个现有的页面,我正试图变成一个Magento网站。我正在处理的一个页面使用了Lightbox。我尝试在CMS页面中通过Design包含灯箱文件。内容相同,但在那里不起作用。有没有什么办法可以包含上一个网站的灯箱javascript而无需触摸xml,html和php文件?如何使灯箱在网站上运行?
答案 0 :(得分:1)
通过将以下内容添加到CMS页面的设计选项卡中,您始终可以将javascript文件添加到页面的头部(请注意该路径是相对于根js目录的)。但是,如果您打算在多个页面上使用灯箱,这将不是首选方法,因为您必须将其复制到您需要的每个页面的设计选项卡中。
<reference name="head">
<action method="addJs"><js>custom/lightboxjs</js></action>
</reference>
答案 1 :(得分:0)
<强> View.PHTML 强>
<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
<script type="text/javascript">
var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
</script>
<?php $config = Mage::getStoreConfig('mdloption/product-type-option'); ?>
<?php if($config['product-view-option'] !=2 && $config['product-view-option'] !=3): ?>
<?php $classnNum ='span9'?>
<?php else:?>
<?php $classnNum ='f-fix'?>
<?php endif; ?>
<?php if($config['product-view-option']==3):?>
<?php $classnNum2 = 'left-carousel'?>
<?php endif; ?>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<div class="product-view <?php echo $classnNum; ?>">
<!--<a class="prePage" href="<?php //echo $_SESSION['core']['last_url'];?>"><?php //echo $this->__('Return to Previous Page')?></a>-->
<!--Prev/Next Code Start-->
<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct();
$prev_url = $next_url = $url = $_product->getProductUrl();
if ($this->helper('catalog/data')->getCategory()) {
$category = $this->helper('catalog/data')->getCategory();
} else {
$_ccats = $this->helper('catalog/data')->getProduct()->getCategoryIds();
$category = Mage::getModel('catalog/category')->load($_ccats[0]);
}
$children = $category->getProductCollection();
$_count = is_array($children) ? count($children) : $children->count();
if ($_count) {
foreach ($children as $product) {
$plist[] = $product->getId();
}
$current_pid = $this->helper('catalog/data')->getProduct()->getId();
$curpos = array_search($current_pid, $plist);
$previd = isset($plist[$curpos+1])? $plist[$curpos+1] : $current_pid;
$product = Mage::getModel('catalog/product')->load($previd);
$prevpos = $curpos;
while (!$product->isVisibleInCatalog()) {
$prevpos += 1;
$nextid = isset($plist[$prevpos])? $plist[$prevpos] : $current_pid;
$product = Mage::getModel('catalog/product')->load($nextid);
}
$prev_url = $product->getProductUrl();
$nextid = isset($plist[$curpos-1])? $plist[$curpos-1] : $current_pid;
$product = Mage::getModel('catalog/product')->load($nextid);
$nextpos = $curpos;
while (!$product->isVisibleInCatalog()) {
$nextpos -= 1;
$nextid = isset($plist[$nextpos])? $plist[$nextpos] : $current_pid;
$product = Mage::getModel('catalog/product')->load($nextid);
}
$next_url = $product->getProductUrl();
}
?>
<!--Prev/Next Code End-->
<div class="product-essential">
<div class="product-img-box span6 <?php echo $classnNum2;?>"> <?php echo $this->getChildHtml('media') ?> </div>
<div class="productDetailBox span6">
<form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
<div class="no-display">
<input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
<input type="hidden" name="related_product" id="related-products-field_1" value="" />
</div>
<div class="product-shop">
<div class="product_left f-fix">
<div class="nextPre">
<!-- <a rel="tooltip" data-placement="left" title="<?php echo $this->__('No Products')?>" class="prod-prev disable" href="JavaScript:void(0);">Prev</a>
<a rel="tooltip" data-placement="right" title="<?php echo $this->__('No Products')?>" class="prod-next disable" href="JavaScript:void(0);">NEXT</a>-->
<?php if ($url <> $prev_url):?>
<a class="prod-next" rel="tooltip" data-placement="right" title="<?php echo $this->__('Volgende product')?>" href="<?php echo $prev_url; ?>"><i class="fa fa-angle-right"></i></a>
<?php endif; ?>
<?php if ($url <> $next_url):?>
<a rel="tooltip" data-placement="left" title="<?php echo $this->__('Vorige product')?>" class="prod-prev" href="<?php echo $next_url; ?>"><i class="fa fa-angle-left"></i></a>
<?php endif; ?>
</div>
<div class="product-name">
<h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
</div>
<div class="review"> <?php echo $this->getReviewsSummaryHtml($_product, false, true)?> </div>
<div class="stock_box">
<?php if ($_product->isAvailable()): ?>
<p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('<i class="fa fa-check-circle"></i> Beschikbaar') ?></span></p>
<?php else: ?>
<p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('<i class="fa fa-times-circle"></i> Verkocht') ?></span></p>
<?php endif; ?>
</div>
<?php if ($_product->getShortDescription()):?>
<div class="short-description">
<div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
</div>
<?php endif;?>
<div class="pro-left">
<div class="add_to_cart">
<?php if (!$this->hasOptions()):?>
<div class="add-to-box">
<?php if($_product->isSaleable()): ?>
<?php echo $this->getChildHtml('addtocart') ?>
<?php endif; ?>
<div class="price_box">
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<?php echo $this->getTierPriceHtml()?>
</div>
</div>
<?php endif; ?>
<?php echo $this->getChildHtml('other');?>
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml('container1', '', true, true) ?>
<?php endif;?>
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml('container2', '', true, true) ?>
<div class="price_box">
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<?php echo $this->getTierPriceHtml()?>
</div>
<?php endif;?>
<div class="clear"></div>
</div>
<div class="f-fix">
<?php echo $this->getChildHtml('extrahint') ?>
<?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
<?php endif; ?>
<?php echo $this->getChildHtml('addto') ?>
<?php if ($this->canEmailToFriend()): ?>
<p class="email-friend"><a rel="tooltip" data-placement="top" title="<?php echo $this->__('Email to a Friend') ?>" href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><i class="fa fa-envelope"></i> <?php echo $this->__('Email to a Friend') ?></a></p>
<?php endif; ?>
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style ">
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_preferred_2"></a>
<a class="addthis_button_preferred_3"></a>
<a class="addthis_button_preferred_4"></a>
<a class="addthis_button_compact"></a>
<a class="addthis_counter addthis_bubble_style"></a>
</div>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4f74bbe87b978120"></script>
<!-- AddThis Button END -->
</div>
</div>
</div>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('static_links')->toHtml() ?>
</div>
</form>
</div>
<div class="product-collateral" id="tabs">
<?php echo $this->getChildHtml('info_tabs') ?>
</div>
</div>
</div>
<?php if($config['product-view-option'] !=2 && $config['product-view-option'] !=3): ?>
<div class="product_right span3">
<?php $config = Mage::getStoreConfig('mdloption/upsellsetting'); ?>
<?php if($config['upsellblocks']==1):?>
<?php echo $this->getChildHtml('upsell_products'); ?>
<?php elseif($config['upsellblocks']==2):?>
<?php if($_product->getUpsellProducts()): ?>
<?php echo $this->getChildHtml('upsell_products'); ?>
<?php else: ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('productBanner')->toHtml() ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('product_custom_block')->toHtml() ?>
<?php endif ?>
<?php elseif($config['upsellblocks']==3):?>
<?php echo $this->getChildHtml('upsell_products'); ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('productBanner')->toHtml() ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('product_custom_block')->toHtml() ?>
<?php endif;?>
<div class="staticSidebar">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('product-static-box')->toHtml() ?>
</div>
</div>
<?php endif; ?>
<?php //echo $this->getChildHtml('upsell_products'); ?>
<?php //echo $this->getChildHtml('related'); ?>
<script type="text/javascript">
//<![CDATA[
var productAddToCartForm = new VarienForm('product_addtocart_form');
productAddToCartForm.submit = function(button, url) {
if (this.validator.validate()) {
var form = this.form;
var oldUrl = form.action;
if (url) {
form.action = url;
}
var e = null;
try {
this.form.submit();
} catch (e) {
}
this.form.action = oldUrl;
if (e) {
throw e;
}
if (button && button != 'undefined') {
button.disabled = true;
}
}
}.bind(productAddToCartForm);
productAddToCartForm.submitLight = function(button, url){
if(this.validator) {
var nv = Validation.methods;
delete Validation.methods['required-entry'];
delete Validation.methods['validate-one-required'];
delete Validation.methods['validate-one-required-by-name'];
// Remove custom datetime validators
for (var methodName in Validation.methods) {
if (methodName.match(/^validate-datetime-.*/i)) {
delete Validation.methods[methodName];
}
}
if (this.validator.validate()) {
if (url) {
this.form.action = url;
}
this.form.submit();
}
Object.extend(Validation.methods, nv);
}
}.bind(productAddToCartForm);
//]]>
</script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("a[rel=example_group]").fancybox({
hideOnContentClick : true,
showNavArrows : false,
arrows : false,
showTitle : false,
scrolling : 'no',
'transitionIn' : 'none',
'transitionOut' : 'none',
'titlePosition' : 'over',
'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' ' + title : '') + '</span>';
}
});
});
</script>