vm scroller
hallo csshunter,
bedankt voor je antwoord.
ten eerste even de link naar het xmlbestand van de mod_productscroller:
http://www.jeelsites.nl/mod_productscroller/mod_productscroller.xml
het phpbestand ziet er zo uit: (zie helemaal onder):
ik heb er al mee zitten klooien, niet met deze, in de code. je ziet allerlei variabelen. die zijn vooringesteld en zou je dan moeten kunnen veranderen. maar dat gaf weinig resultaat wat de margin van de titel tot het plaatje betreft.
bovendien heeft ie nog wat minder leuke kanten:
1. in firefox (3. nog wat) dus maar 3 vd 10 plaatjes
2. geen breuklijnen tussen de producten zoals in IE (1-0 voor IE, het mag ook wel eens gezegd worden!)
3. zodra er een verticaal plaatje (thumbnail) getoond moet worden is ie helemaal van de waps (prijs IN het plaatje) maar daar heeft IE dacht ik ook een probleem mee).
het mooiste zou zijn: Titel <br /> plaatje <br /> info
als je begrijpt wat ik bedoel.
ik heb trouwens enkele nieuwe scrollers gegoogled, je kunt ze zien op
www.jeelsites.nl/joomla, aan de rechterzijde. ze werken in andere browsers prima. ze 'scrollen' dan wel niet, kun je ook niet instellen, wel hoe de overgang plaatsvindt, fade etc, maar werken tenminste naar behoren. inderdaad met vaste positie, zoals je noemt.
n javascript-scroller zeg je...hmm, daar weet ik niet veel van, van javascript. is php niet veel eenvoudiger?
over zo'n javascript scroller: kan ik die dan wijsmaken dat ik de plaatjes wil vertonen uit de productenlijst van virtuemart? die je dus uit de database haalt. dat moet je toch doen met php (aangezien er steeds nieuwe plaatjes bijkomen die getoond moeten worden)? of sla ik de plank volledig mis?
hier haak ik een beetje af, want dat wordt dan programmeren.
dan als laatste:
Maar wederom: of dit in het Virtuemart-system haalbaar is, geen idee.
Het zou kunnen dat deze dingen (inclusief alle inline styles) er dynamisch in gezet zijn met php, dat kan ik van buitenaf niet zien. Dan kan het nog best gecompliceerd worden om dat aan te passen.
Maar misschien valt er iets op te maken uit het php-bestand en de xml van deze module. Hoe zien die er uit?
Met vriendelijke groet,
CSShunter
___________
PS: De "product name div" is 77px hoog, daar gaat 15px van af via de negatieve margin-top van de "product image div", en dan is het niet verwonderlijk dat er een gapend gat komt na de ene regel tekst met de productnaam.
bedoel je of er een cssbestand te zien is ergens? ik heb het niet kunnen ontdekken, weet ook niet waar ie die margens vandaan tovert.
heb nog wel een bestand bijgevoegd, de backend.
ps:
ik wist trouwens helemaal niet dat die marquee-techniek nog gebruikt werd. dat is toch not done en helemaal uit de tijd?
zou met html5 zoiets niet veel makkelijker worden? dat je invoert:
Introductie van het element Scroll.
<scroll><div1 margeonder=4>je inhoud><div2>danplaatje</div2><div3 margeonder=4>je inhoud</div3></scroll>.
hmm, ik zal dit even opsturen naar de werkgroep html5, die zullen daar vast blij mee zijn.
Code:
<?php
/**
* VirtueMart Product Scroller Module
* NOTE: THIS MODULE REQUIRES AN INSTALLED VirtueMart COMPONENT!
*
* @version $Id: mod_productscroller.php 1948 2009-09-30 14:32:48Z soeren_nb $
* @package VirtueMart
* @subpackage modules
*
* @copyright (C) 2005-2007 Soeren Eberhardt
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*
* VirtueMart is Free Software.
* VirtueMart comes with absolute no warranty.
*/
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
global $my, $mosConfig_absolute_path;
// Load the virtuemart main parse code
if( file_exists(dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' )) {
require_once( dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' );
} else {
require_once( dirname(__FILE__).'/../components/com_virtuemart/virtuemart_parser.php' );
}
/**
* This class sets all Parameters.
* Must first call the MOS function, something like:
* $params = mosParseParams( $module->params );
* and send the $params variable to this class (productScroller)
* @param $params the results from mosParseParams( $module->params );
* @example $scroller = new productScroller($params);
*/
if( !class_exists('productScroller')) { // Prevent double class declaration
class productScroller {
/**
* @var $NumberOfProducts
*/
var $NumberOfProducts = 5;
/**
* @var $featuredProducts
*/
var $featuredProducts = false;
/**
* // scroll, alternate, slide
* @var $ScrollBehavior
*/
var $ScrollBehavior = 'scroll';
/**
* @var $PS_DIRECTION
*/
var $ScrollDirection = 'up';
/**
* @var $ScrollHeight
*/
var $ScrollHeight = '150';
/**
* @var $ScrollWidth
*/
var $ScrollWidth = '180';
/**
* @var $ScrollAmount
*/
var $ScrollAmount = '2';
/**
* @var $ScrollDelay
*/
var $ScrollDelay = '80';
/**
* @var $ScrollAlign
*/
var $ScrollAlign = 'center';
/**
* // newest [asc], oldest [desc], random [rand]
* @var $SortMethod
*/
var $ScrollSortMethod = 'random';
/**
* @var $ScrollTitles
*/
var $ScrollTitles = 'yes';
/**
* @var $ScrollSpaceChar
*/
var $ScrollSpaceChar = ' ';
/**
* @var $ScrollSpaceCharTimes
*/
var $ScrollSpaceCharTimes = 5;
/**
* @var $ScrollLineChar
*/
var $ScrollLineChar = '<br />';
/**
* @var $ScrollLineCharTimes
*/
var $ScrollLineCharTimes = 2;
/**
* @var $ScrollSection
*/
var $ScrollSection = 0;
// CSS override -----------------------
/**
* @var $ScrollCSSOverride
*/
var $ScrollCSSOverride = 'no';
/**
* @var $ScrollTextAlign
*/
var $ScrollTextAlign = 'left';
/**
* @var $ScrollTextWeight
*/
var $ScrollTextWeight = 'normal';
/**
* @var $ScrollTextSize
*/
var $ScrollTextSize = '10';
/**
* @var $ScrollTextColor
*/
var $ScrollTextColor = '#000000';
/**
* @var $ScrollBGColor
*/
var $ScrollBGColor = 'transparent';
/**
* @var $ScrollMargin
*/
var $ScrollMargin = '2';
var $params = null;
/**
* set mammeters
*/
function productScroller (&$params) {
$this->params = $params;
// standard mammeters
$this->show_product_name = $params->get('show_product_name', "yes");
$this->show_addtocart = $params->get('show_addtocart', "yes");
$this->show_price = $params->get('show_price', "yes");
$this->category_id = intval( $params->get('category_id', 0 ) );
// Limit by NoP
$this->NumberOfProducts = $params->get('NumberOfProducts', $this->NumberOfProducts);
$this->featuredProducts = $params->get('featuredProducts', $this->featuredProducts);
$this->ScrollSection = $params->get('ScrollSection', $this->ScrollSection);
$this->ScrollBehavior = $params->get('ScrollBehavior', $this->ScrollBehavior);
$this->ScrollDirection = $params->get('ScrollDirection', $this->ScrollDirection);
$this->ScrollHeight = $params->get('ScrollHeight', $this->ScrollHeight);
$this->ScrollWidth = $params->get('ScrollWidth', $this->ScrollWidth);
$this->ScrollAmount = $params->get('ScrollAmount', $this->ScrollAmount);
$this->ScrollDelay = $params->get('ScrollDelay', $this->ScrollDelay);
$this->ScrollAlign = $params->get('ScrollAlign', $this->ScrollAlign);
$this->ScrollSortMethod = $params->get('ScrollSortMethod', $this->ScrollSortMethod);
$this->ScrollTitles = $params->get('ScrollTitles', $this->ScrollTitles);
$this->ScrollSpaceChar = $params->get('ScrollSpaceChar', $this->ScrollSpaceChar);
$this->ScrollSpaceCharTimes = $params->get('ScrollSpaceCharTimes', $this->ScrollSpaceCharTimes);
$this->ScrollLineChar = $params->get('ScrollLineChar', $this->ScrollLineChar);
$this->ScrollLineCharTimes = $params->get('ScrollLineCharTimes', $this->ScrollLineCharTimes);
// customization mammeters
$this->ScrollCSSOverride = $params->get('ScrollCSSOverride', $this->ScrollCSSOverride);
$this->ScrollTextAlign = $params->get('ScrollTextAlign', $this->ScrollTextAlign);
$this->ScrollTextWeight = $params->get('ScrollTextWeight', $this->ScrollTextWeight);
$this->ScrollTextSize = $params->get('ScrollTextSize', $this->ScrollTextSize);
$this->ScrollTextColor = $params->get('ScrollTextColor', $this->ScrollTextColor);
$this->ScrollBGColor = $params->get('ScrollBGColor', $this->ScrollBGColor);
$this->ScrollMargin = $params->get('ScrollMargin', $this->ScrollMargin);
}
/**
* Display Product Data
*/
function displayScroller (&$rows) {
global $mosConfig_absolute_path;
$database = new ps_DB();
require_once( CLASSPATH."ps_product.php" );
$ps_product = new ps_product;
$cnt=0;
if($this->ScrollCSSOverride=='yes') {
$txt_size = $this->ScrollTextSize . 'px';
$margin = $this->ScrollMargin . 'px';
//$height=($height-intval($margin+0));
//$width=($width-intval($margin+30));
echo $this->params->get( 'pretext', "");
echo " <div style=\"text-align:".$this->ScrollAlign.";background-color: ".$this->ScrollBGColor."; width:".$this->ScrollWidth."px;
margin-top: $margin; margin-right: $margin; margin-bottom: $margin; margin-left: $margin;\" >
<marquee behavior=\"".$this->ScrollBehavior."\"
direction=\"".$this->ScrollDirection."\"
height=\"".$this->ScrollHeight."\"
width=\"".$this->ScrollWidth."\"
scrollamount=\"".$this->ScrollAmount."\"
scrolldelay=\"".$this->ScrollDelay."\"
truespeed=\"true\" onmouseover=\"this.stop()\" onmouseout=\"this.start()\"
style=\"text-align: ".$this->ScrollTextAlign."; color: ".$this->ScrollTextColor."; font-weight: ".$this->ScrollTextWeight."; font-size: $txt_size;\" >";
}
else {
echo " <div style=\"width:".$this->ScrollWidth."px;text-align:".$this->ScrollAlign.";\">
<marquee behavior=\"".$this->ScrollBehavior."\"
direction=\"".$this->ScrollDirection."\"
height=\"".$this->ScrollHeight."\"
width=\"".$this->ScrollWidth."\"
scrollamount=\"".$this->ScrollAmount."\"
scrolldelay=\"".$this->ScrollDelay."\"
truespeed=\"true\" onmouseover=\"this.stop()\" onmouseout=\"this.start()\">";
}
$show_product_name = ( $this->show_product_name == "yes" ) ? true : false;
$show_addtocart = ( $this->show_addtocart == "yes" ) ? true : false;
$show_price = ( $this->show_price == "yes" ) ? true : false;
if (($this->ScrollDirection=='left') || ($this->ScrollDirection=='right')) {
echo '<table border="0"><tr>';
}
foreach($rows as $row) {
if (($this->ScrollDirection=='left') || ($this->ScrollDirection=='right')) {
echo '<td style="vertical-align:top;padding: 2px 5px 2px 5px;">';
}
$ps_product->show_snapshot( $row->product_sku, $show_price, $show_addtocart, $show_product_name );
if (($this->ScrollDirection=='left') || ($this->ScrollDirection=='right')) {
echo '</td>';
} else {
for($i=0;$i<$this->ScrollLineCharTimes;$i++) {
echo $this->ScrollLineChar;
}
}
}
if (($this->ScrollDirection=='left') || ($this->ScrollDirection=='right')) {
echo '</tr></table>';
}
echo " </marquee>
</div>";
} // end displayScroller
} // end class productScroller
/**
* Helper DB function
*/
function getProductSKU( $limit=0, $how=null, $category_id=0, $featuredProducts='no' ) {
global $my, $mosConfig_offset;
$database = new ps_DB();
if($limit>0) {
$limit = "LIMIT $limit";
} else {
$limit = "";
}
$query = "SELECT p.product_sku FROM #__{vm}_product AS p";
$query .= "\nJOIN #__{vm}_product_category_xref as pc ON p.product_id=pc.product_id";
if( $category_id != 0 ) {
$query .= " AND pc.category_id=$category_id";
}
$query .= "\nJOIN #__{vm}_category as c ON pc.category_id=c.category_id";
$query .= "\n WHERE p.product_publish = 'Y' AND c.category_publish = 'Y' AND product_parent_id=0 ";
if( CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != "1") {
$query .= " AND product_in_stock > 0 ";
}
if( $featuredProducts=='yes' ) {
$query .= "\n AND product_special = 'Y' ";
}
switch( $how ) {
case 'random':
$query .= "\n ORDER BY RAND() $limit";
break;
case 'newest':
$query .= "\n ORDER BY p.cdate DESC $limit";
break;
case 'oldest':
$query .= "\n ORDER BY p.cdate ASC $limit";
break;
default:
$query .= "\n ORDER BY p.cdate DESC $limit";
break;
}
$database->query( $query );
$rows = $database->record;
return $rows;
}
}
// start of Product Scroller Script
$params = new vmParameters( $module->params );
$scroller = new productScroller($params);
/**
* Load Products
**/
$rows = getProductSKU( $scroller->NumberOfProducts, $scroller->ScrollSortMethod, $scroller->category_id, $scroller->featuredProducts );
/**
* Display Product Scroller
**/
$scroller->displayScroller($rows);
?>