How to make codnitive sidenav slide up/down? - javascript

I have the magneto extension "Codnitive Sidenav" but in order to make it slideUp/Down
some extra coding is needed.
the original navigation.phtml code for sidenav is:
<?php if ($categories = $this->getCategoriesNavMenu()): ?>
<div id="sidebar-nav" class="block sidebar-nav-left <?php echo $this- >getBlockAlias() ?>">
<div class="block-title">
<strong><span><?php echo $this->__($this->getTitle()) ?></span></strong>
</div>
<div class="block-content">
<ul id="sidebar-nav-menu">
<?php if ($this->showHome()): ?>
<li class="<?php echo $this->getHomeClasses() ?>">
<a title="Go to Home Page" href="<?php echo $this->getBaseUrl() ?>"><span class="category_name"></span></a>
</li>
<?php endif; ?>
<?php echo $categories; ?>
</ul>
<?php if ($this->showSupportLogo()): ?>
<div class="clearer support-logo-wrapper"></div>
<a href="http://www.codnitive.com/" target="_blank" class="support_logo">
<?php if ($this->showAsImage()): ?>
<img src="<?php echo $this->getSkinUrl('images/codnitive/sidenav/codnitive_logo.png'); ?>" alt="CODNITIVE®" title="Sidebar Navigation by CODNITIVE"/>
<?php else: ?>
<span>CODNITIVE&REG;</span>
<?php endif; ?>
</a>
<?php endif; ?>
</div>
<?php if ($this->getConfig()->isCollapsible()): ?>
<script type="text/javascript" language="javascript">
//<![CDATA[
Codnitive = {
expandMenu: function(parent)
{
var mode = parent.getElementsByTagName("ul")[0].getAttribute("expanded");
(mode == 1) ? Codnitive.collapse(parent) : Codnitive.expand(parent);
},
expand: function(parent)
{
parent.getElementsByTagName("ul")[0].style.display = "block";
parent.getElementsByTagName("span")[0].style.backgroundPosition = "right center";
parent.getElementsByTagName("ul")[0].setAttribute("expanded", "1");
},
collapse: function(parent)
{
parent.getElementsByTagName("ul")[0].style.display = "none";
parent.getElementsByTagName("span")[0].style.backgroundPosition = "left center";
parent.getElementsByTagName("ul")[0].setAttribute("expanded", "0");
}
};
//]]>
</script>
<?php endif; ?>
and the original code for navigation.php is:
<?php
*/
public function getConfig()
{
if ($this->_config === null) {
$this->_config = Mage::getModel('sidenav/config');
}
return $this->_config;
}
/**
* Get store categories navigation menu
*
* #return string
*/
public function getCategoriesNavMenu()
{
$navigationMenu = $this->renderCategoriesMenuHtml(0);
return $navigationMenu ? $navigationMenu : false;
}
/**
* We set cache to null when product direct access option is enabled and customer
* is in product page to avoid wrong category tree showing with enabled caches
*
* Adds 1 extra second to page load
* Ultra version has caching and best performance
*
* #return null
*/
public function getCacheLifetime()
{
$condition = (Mage::registry('current_product') !== null)
&& ($this->getConfig()->activeProductCategoriesInDirectAccess());
if ($condition) {
return null;
}
return parent::getCacheLifetime();
}
/**
* Get catagories of current store
*
* #return Varien_Data_Tree_Node_Collection
*/
public function getStoreCategories()
{
return Mage::helper('sidenav/category')->getStoreCategories();
}
/**
* Returns category model
*
* #return Codnitive_Sidenav_Model_Category
*/
protected function _getCategoryModel()
{
return Mage::getModel('sidenav/catalog_category');
}
/**
* Retruns data helper
*
* #return Codnitive_Sidenav_Helper_Data
*/
protected function _getHelper()
{
return Mage::helper('sidenav');
}
/**
* Render category to html
*
* #param Mage_Catalog_Model_Category $category
* #param int Nesting level number
* #param boolean Whether ot not this item is last, affects list item class
* #param boolean Whether ot not this item is first, affects list item class
* #param boolean Whether ot not this item is outermost, affects list item class
* #param string Extra class of outermost list items
* #param string If specified wraps children list in div with this class
* #param boolean Whether ot not to add on* attributes to list item
* #return string
*/
protected function _renderCategoryMenuItemHtml(
$category, $level = 0, $isLast = false,
$isFirst = false, $isOutermost = false, $outermostItemClass = '',
$childrenWrapClass = '', $noEventAttributes = false
) {
if (!$category->getIsActive()) {
return '';
}
$config = $this->getConfig();
$html = array();
$expanded = null;
$ulThumb = '';
$image = '';
$thumb = '';
$htmlLi = '';
// get all children
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = (array) $category->getChildrenNodes();
$childrenCount = count($children);
}
else {
$children = $category->getChildren();
if (!$this->_getHelper()->isSearchResultsPage()) {
$childrenCount = $children->count();
}
else {
if (is_string($children)) {
$children = explode(',', $children);
}
$childrenCount = count($children);
}
}
// select active children
$activeChildren = array();
foreach ($children as $child) {
if ($child->getIsActive()) {
$activeChildren[] = $child;
}
}
$activeChildrenCount = count($activeChildren);
$hasActiveChildren = ($activeChildrenCount > 0);
// prepare list item html classes
$classes = array();
$classes[] = 'level' . $level;
$classes[] = 'nav-' . $this->_getItemPosition($level);
if ($this->isCategoryActive($category)) {
$classes[] = 'active';
}
else if ((Mage::registry('current_product') !== null) && ($config->activeProductCategoriesInDirectAccess())) {
$classes = $this->_getCategoryModel()->getProductCategoriesInDirectAccess($category, $classes);
}
$linkClass = '';
if ($isOutermost && $outermostItemClass) {
$classes[] = $outermostItemClass;
$linkClass = ' class="' . $outermostItemClass . '"';
}
if ($isFirst) {
$classes[] = 'first';
}
if ($isLast) {
$classes[] = 'last';
}
if ($hasActiveChildren) {
$classes[] = 'parent';
}
// prepare list item attributes
$attributes = array();
if (count($classes) > 0) {
$attributes['class'] = implode(' ', $classes);
}
if ($hasActiveChildren && !$noEventAttributes) {
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';
}
// assemble list item with attributes
$thumbWidth = 14;
$thumbHeight = 14;
$thumbPosition = $config->getThumbPosition();
$liMarginLeft = 0;
$ulMarginLeft = 5;
$ulPaddingLeft = 10;
// define image thumbnail variables
if ($config->isThumbImageActive()) {
if ($config->getThumbSize()) {
$thumbWidth = $config->getThumbWidth();
$thumbHeight = $config->getThumbHeight();
}
$thumbnail = $this->_getCategoryModel()->load($category->getId())->getThumbnailImageUrl();
$ulThumb = ' ul-thumb';
if (!empty($thumbnail)) {
$image = '<img class="thumb-img-' . $thumbPosition . '" src="' . $thumbnail . '" style= "width:' . $thumbWidth . 'px; height:' . $thumbHeight . 'px; float: ' . $thumbPosition . ';" />';
$thumb = ' thumb';
if ($thumbPosition === 'left') {
if ($config->isCollapsible() && $config->isThumbImageActive()) {
$liMarginLeft = $thumbWidth + 3;
$ulMarginLeft = 0;
}
else {
$liMarginLeft = 0;
$ulMarginLeft = $thumbWidth + 3;
}
$ulPaddingLeft = 0;
}
}
else {
$thumb = ' no-thumb';
$liMarginLeft = ($thumbPosition === 'right') ? 0 : $thumbWidth + 3;
if ($thumbPosition === 'left') {
$ulMarginLeft = 0;
$ulPaddingLeft = 0;
}
}
}
$collapsibleClass = '';
if ($config->isCollapsible()) {
$collapsibleClass = ' collapsible';
}
// add collapsible arrow and wrraper
$arrow = '';
$extraStyle = '';
$collapsibleIconPosition = $config->getCollapsibleIconPosition();
if ($config->isCollapsible()) {
$width = $config->getCollapsibleIconType() === 'arrow' ? 8 : 16;
$height = 0;
$expanded = 0;
if ($hasActiveChildren) {
$width = $config->getCollapsibleIconType() === 'arrow' ? 8 : 16;
$height = 16;
}
if ($height == 0) {
$extraStyle = ' display:none;';
}
if ($height == 0 && $collapsibleIconPosition === 'left') {
$liMarginLeft += $width;
}
if ($this->isCategoryActive($category)) {
$expanded = 1;
}
$expanded = ' expanded="' . $expanded .'"';
$spanOnclick = 'onclick="Codnitive.expandMenu(this.parentNode)';
$spanClass = $config->getCollapsibleIconType() . '-' . $collapsibleIconPosition;
$arrow = '<span class="' . $spanClass . ' " ' . $spanOnclick . '" style="width: ' . $width . 'px; height: ' . $height . 'px;' . $extraStyle . '"></span>';
}
$htmlLi .= '<li';
foreach ($attributes as $attrName => $attrValue) {
$htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\"', $attrValue) . $thumb . $collapsibleClass . '"';
}
$htmlLi .= ' style="margin-left: ' . $liMarginLeft . 'px;' . '">';
$html[] = $htmlLi;
$html[] = $arrow;
// add wrapper
$aClass = '';
$aStyle = '';
$onclick = '';
if ($config->isCollapsible() || $config->isThumbImageActive()) {
$wrapperMargin = ($config->isCollapsible() && $collapsibleIconPosition === 'left') ? 14 : 0;
$extraMargin = !$config->isThumbImageActive() ? 0 : (!empty($thumbnail) && ($thumbPosition === 'left')) ? $thumbWidth + 3 : 0;
$collWrapper = $wrapperMargin + $extraMargin;
// makes parent category name clickable to open/close collapsible menus if option is enabled
$collapseName = '';
if ($hasActiveChildren && $config->isCollapsible() && $config->expandByParentName()) {
$onclick = ' onclick="Codnitive.expandMenu(this.parentNode);return false;"';
$collapseName = ' collapse-name';
}
$aClass = 'class="collapsible-wrapper' . $collapseName . '"';
$aStyle = ' style="margin-left: ' . $collWrapper . 'px;"';
}
$html[] = '<a ' . $aClass . $onclick . 'href="' . $this->getCategoryUrl($category) . '"'
. $linkClass .'>' . '<span class="category_name">'
. $this->escapeHtml($category->getName()) . '</span></a>';
// add thumbnail image
$html[] = $image;
// add product count
if ($config->showProductCount()) {
$count = Mage::getModel('catalog/layer')
->setCurrentCategory($category->getID())
->getProductCollection()
->getSize();
if (($config->removeZeroCount() && $count > 0) || !$config->removeZeroCount()) {
$html[] = '<span class="product-count">(' . $count . ')</span>';
}
}
// render children
$htmlChildren = '';
$j = 0;
foreach ($activeChildren as $child) {
$htmlChildren .= $this->_renderCategoryMenuItemHtml(
$child, ($level + 1), ($j == $activeChildrenCount - 1), ($j == 0), false, $outermostItemClass, $childrenWrapClass, $noEventAttributes
);
$j++;
}
if (!empty($htmlChildren)) {
if ($childrenWrapClass) {
$html[] = '<div class="' . $childrenWrapClass . '">';
}
$html[] = '<ul class="level' . $level . $ulThumb . $collapsibleClass .
'" style="margin-left: ' . $ulMarginLeft .
'px; padding-left: ' . $ulPaddingLeft . 'px;"' . $expanded . '>';
$html[] = $htmlChildren;
$html[] = '</ul>';
if ($childrenWrapClass) {
$html[] = '</div>';
}
}
$html[] = '</li>';
$html = implode("\n", $html);
return $html;
}
/**
* Render categories menu in HTML
*
* #param int Level number for list item class to start from
* #param string Extra class of outermost list items
* #param string If specified wraps children list in div with this class
* #return string
*/
public function renderCategoriesMenuHtml($level = 0, $outermostItemClass = '', $childrenWrapClass = '')
{
$currentId = Mage::app()->getStore()->getRootCategoryId();
$currentLevel = $this->_getCategoryModel()->load($currentId)->getLevel();
if ($registerdCategory = Mage::registry('current_category')) {
$currentId = $registerdCategory->getId();
$currentLevel = $registerdCategory->getLevel();
}
$config = $this->getConfig();
$paretnType = $config->getParent();
$categories = $this->getStoreCategories();
$activeCategories = array();
foreach ($categories as $child) {
// this condition use for "Current Category and Children" option
$condition = ($paretnType == 'current')
&& ($child->getLevel() == $currentLevel)
&& ($child->getId() != $currentId);
if ($child->getIsActive() && !$condition) {
$activeCategories[] = $child;
}
}
$activeCategoriesCount = count($activeCategories);
$hasActiveCategoriesCount = ($activeCategoriesCount > 0);
if (!$hasActiveCategoriesCount) {
return '';
}
$html = '';
$j = 0;
foreach ($activeCategories as $category) {
$html .= $this->_renderCategoryMenuItemHtml(
$category, $level, ($j == $activeCategoriesCount - 1),
($j == 0), true, $outermostItemClass, $childrenWrapClass, true
);
$j++;
}
return $html;
}
/**
* Get category title
*
* #return string
*/
public function getTitle()
{
$title = '';
$currentCategory = Mage::registry('current_category');
switch ($this->getConfig()->getTitleType()) {
case 'current':
if ($currentCategory) {
$title = $currentCategory->getName();
}
break;
case 'parent':
if ($currentCategory) {
$parent = $currentCategory->getParentCategory();
$rootId = Mage::app()->getStore()->getRootCategoryId();
if ($parent->getId() != $rootId) {
$title = $parent->getName();
}
}
break;
case 'static':
$title = $this->getConfig()->getStaticTitle();
}
if (!$title) {
$title = $this->getConfig()->getStaticTitle();
}
return $title;
}
/**
* Retrieves home page link must show
*
* #return boolean
*/
public function showHome()
{
if ($this->_getHelper()->isHome() && $this->getConfig()->removeHomeInHome()) {
return false;
}
return $this->getConfig()->showHome();
}
/**
* Returns all classes for home link
*
* #return string
*/
public function getHomeClasses()
{
$classes = 'level0 nav-0 parent home';
if ($this->getConfig()->isCollapsible()) {
$classes .= ' collapsible';
}
if ($this->_getHelper()->isHome()) {
$classes .= ' active';
}
return $classes;
}
/**
* Retrieves which CODNITIVE logo must show or not
*
* #return boolean
*/
public function showSupportLogo()
{
return $this->getConfig()->showSupportLogo();
}
/**
* Retrieves which CODNITIVE logo must show as image or text
*
* #return boolean
*/
public function showAsImage()
{
return $this->getConfig()->showAsImage();
}
/**
* Get extension enable status
*
* #deprecated after 1.7.20
* We don't need to check for module activation option
* in template, we check it in layout.
*
* #return boolean
*/
public function isActive()
{
return $this->getConfig()->isActive();
}
/**
* Get selected column
*
* #deprecated after 1.7.20
* We don't need to check for selected column option
* in template, we check it in layout.
*
* #return string
*/
public function getColumn()
{
return $this->getConfig()->getColumn();
}
}
I was told to replace the javascript code in navigation.phtml with the code here below:
(function($) {
Codnitive = {
sideMenu:
{
expandMenu: function($parent)
{
var $ul = $parent.getElementsByTagName("ul")[0];
var $span = $parent.getElementsByTagName("span")[0];
($ul.getAttribute("expanded") == 1)
? Codnitive.sideMenu.collapse($ul, $span)
: Codnitive.sideMenu.expand($ul, $span);
},
expand: function($ul, $span)
{
$($ul).slideDown(300, function() {
$ul.setAttribute("expanded", "1");
$span.style.backgroundPosition = "right center";
});
},
collapse: function($ul, $span)
{
$($ul).slideUp(400, function() {
$ul.setAttribute("expanded", "0");
$span.style.backgroundPosition = "left center";
});
}
},
})(jQuery);
AND call it like this:
onclick="Codnitive.sideMenu.expandMenu(this.parentNode)"
so I tried this, like so:
$expanded = ' expanded="' . $expanded .'"';
$spanOnclick = 'onclick="Codnitive.expandMenu(this.parentNode)';
$spanClass = $config->getCollapsibleIconType() . '-' . $collapsibleIconPosition;
$arrow = '<span class="' . $spanClass . ' " ' . $spanOnclick . '" style="width: ' . $width . 'px; height: ' . $height . 'px;' . $extraStyle . '"></span>';
and
if ($hasActiveChildren && $config->isCollapsible() && $config->expandByParentName()) {
$onclick = ' onclick="Codnitive.sideMenu.expandMenu(this.parentNode);return false;"';
But it didn't work so my question is: What am I doing wrong here?
does it have to do with the misplacement of " "?
Does anyone know what I should do to make this work?
much obliged,
Tuutuutuut

Related

My pagination is jumping around and I can't figure out how to fix it

I'm making a product listings page that uses AJAX calls to post the user's inputted data:
The pagination uses the jQuery inView function to call the next page
(NextPage.php) when loader.gif is in view
InfiniteScroll.js
$(document).ready(function() {
$('#Loader').on('inview', function(event, isInView) {
if (isInView) {
//Pagination
var nextPage = parseInt($('#pageno').val()) + 1;
//Filters
var minimum_wt = $('#hidden_minimum_wt').val();
var maximum_wt = $('#hidden_maximum_wt').val();
var shape = get_filter('shape');
var color = get_filter('color');
var enhancement = get_filter('enhancement');
var matching = get_filter('matching');
$.ajax({
type: 'POST',
url: 'vendors/php/NextPage.php',
data: {
pageno: nextPage,
minimum_wt: minimum_wt,
maximum_wt: maximum_wt,
shape: shape,
color: color,
enhancement: enhancement,
matching: matching
},
cache: false,
success: function(data) {
console.log(nextPage); //For debugging
if(data != '') {
$('#StoneContainer').append(data);
$('#pageno').val(nextPage);
} else {
$('.LoaderContainer').hide(); //Hide infinite scroll
}
}
});
}
});
});
//Checking applied filters
function get_filter(class_name) {
var filter = [];
$('.'+class_name+':checked').each(function() {
filter.push($(this).val());
});
return filter;
}
NextPage.php
<?php
if(isset($_GET['pageno']) || isset($_POST['action'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = $_POST['pageno'];
}
$limit = 10;
$offset = ($pageno-1) * $limit;
//Include database configuration file
include('dbConfig.php');
$SQL = "
SELECT
number,
image1,
wt,
TRUNCATE(length,1) as length,
TRUNCATE(width,1) as width,
CASE
WHEN stonetype = 'SA' THEN 'Sapphire'
WHEN stonetype = 'RU' THEN 'Ruby'
WHEN stonetype = 'TML-P' THEN 'Paraiba'
WHEN stonetype = 'EM' THEN 'Emerald'
WHEN stonetype = 'TS' THEN 'Tsavorite'
WHEN stonetype = 'SI' THEN 'Spinel'
WHEN stonetype = 'GT' THEN 'Garnet'
WHEN stonetype = 'BER' THEN 'Beryl'
WHEN stonetype = 'TML' THEN 'Tourmaline'
WHEN stonetype = 'KO' THEN 'Kornerupine'
ELSE 'n/a'
END AS 'stonetype',
CASE
WHEN enhcode = 'H' THEN 'Heated'
WHEN enhcode = 'N' THEN 'Unheated'
ELSE 'n/a'
END AS 'enhcode'
FROM
stones
WHERE
wt >= 2.5
";
if(isset($_POST["minimum_wt"], $_POST["maximum_wt"]) && !empty($_POST["minimum_wt"]) && !empty($_POST["maximum_wt"])) {
$SQL .= "
AND wt BETWEEN '".$_POST["minimum_wt"]."' AND '".$_POST["maximum_wt"]."'
";
}
if(isset($_POST["shape"])) {
$shape_filter = implode("','", $_POST["shape"]);
$SQL .= "
AND stoneshape IN('".$shape_filter."')
";
}
if(isset($_POST["color"])) {
$color_filter = implode("','", $_POST["color"]);
$SQL .= "
AND stonecolor IN('".$color_filter."')
";
}
if(isset($_POST["enhancement"])) {
$enhancement_filter = implode("','", $_POST["enhancement"]);
$SQL .= "
AND enhcode IN('".$enhancement_filter."')
";
}
if(isset($_POST["matching"])) {
$matching_filter = implode("','", $_POST["matching"]);
$SQL .= "
AND pair IN('".$matching_filter."')
";
}
$SQL .= "
ORDER BY
wt ASC
LIMIT
" . $offset. ",
" . $limit. "
";
$res_data = mysqli_query($db, $SQL);
if(isset($_POST["minimum_wt"], $_POST["maximum_wt"]) && !empty($_POST["minimum_wt"]) && !empty($_POST["maximum_wt"]) && isset($_POST["shape"]) && isset($_POST["color"]) && isset($_POST["enhancement"]) && isset($_POST["matching"])) {
while($row = mysqli_fetch_array($res_data)) {
echo '
<div class="Stone">
<!-- landing page -->
<a href="#ItemPage" class="ItemLink" rel="modal:open" id="' . $row['number']. '">
<!-- image -->
<div class="StoneData StoneIMG"> <img src="../../../' . $row['image1'] . '"> </div>
<!-- weight -->
<div class="StoneData">' . $row['wt'] . 'Ct</div>
<!-- type -->
<div class="StoneData">' . $row['stonetype'] . '</div>
<!-- enhancement -->
<div class="StoneData">' . $row['enhcode'] . '</div>
<!-- dimensions -->
<div class="StoneData">' . $row['length'] . ' x ' . $row['width'] . '</div>
<!-- item number -->
<div class="StoneData"># ' . $row['number'] . '</div>
</a>
</div>
';
}
}
?>
4 different check box fields and a jQuery range slider so the user
can filter out only the data they want
Filters.js
$(document).ready(function() {
filter_data();
function filter_data() {
var action = 'fetch_data';
//Pagination
var nextPage = parseInt($('#pageno').val()) + 0;
//Filters
var minimum_wt = $('#hidden_minimum_wt').val();
var maximum_wt = $('#hidden_maximum_wt').val();
var shape = get_filter('shape');
var color = get_filter('color');
var enhancement = get_filter('enhancement');
var matching = get_filter('matching');
$.ajax( {
url: 'vendors/php/Filters/FilterData.php',
method: 'POST',
data: {
action: action,
pageno: nextPage,
minimum_wt: minimum_wt,
maximum_wt: maximum_wt,
shape: shape,
color: color,
enhancement: enhancement,
matching: matching
},
async: true,
error:
function(jqXHR, strError) {
if(strError == 'timeout') {
// Do something. Try again perhaps?
alert('Seems like there was an error loading the filters request.');
}
},
success:
function(data) {
$('#StoneContainer').html(data);
$('#pageno').val(nextPage);
$('.LoaderContainer').show(); //Show infinite scroll
},
timeout: 3000
});
}
// Where to find values to be filtered
function get_filter(class_name) {
var filter = [];
$('.'+class_name+':checked').each(function() {
filter.push($(this).val());
});
return filter;
}
// Apply filter_data() of .common_selector
$('.common_selector').click(function() {
filter_data();
});
// Range slider
$('#wt_range').slider({
range: true,
values: [2.5, 30],
min: 2.5,
max: 30,
step: 0.1,
slide:
function(event, ui) {
// prevent thumbs from overlapping
if ((ui.values[1] - ui.values[0]) < 3) {
return false;
}
$('#wt_show').html(ui.values[0] + 'Ct - ' + ui.values[1] + 'Ct');
$('#hidden_minimum_wt').val(ui.values[0]);
$('#hidden_maximum_wt').val(ui.values[1]);
filter_data();
}
});
// open and close filters menu on mobile
if ($('#StoneContainer').width() < 420 ) {
$('.OpenCloseFilters').on('click', function() {
$('.FiltersContainer').slideToggle();
// refresh button
$('.ResetFiltersToggle0').toggleClass('ResetFiltersToggle1');
// change icon on toggle
$('#MenuIcon').toggleClass('mdi-menu-up mdi-menu-down');
});
}
});
FilterData.php
<?php
if(isset($_POST['pageno']) || isset($_POST['action'])) {
//Include database configuration file
include('../dbConfig.php');
$limit = 10;
$offset = !empty($_POST['pageno']) ? $_POST['pageno']: 0;
$SQL = "
SELECT
number,
image1,
wt,
TRUNCATE(length,1) as length,
TRUNCATE(width,1) as width,
CASE
WHEN stonetype = 'SA' THEN 'Sapphire'
WHEN stonetype = 'RU' THEN 'Ruby'
WHEN stonetype = 'TML-P' THEN 'Paraiba'
WHEN stonetype = 'EM' THEN 'Emerald'
WHEN stonetype = 'TS' THEN 'Tsavorite'
WHEN stonetype = 'SI' THEN 'Spinel'
WHEN stonetype = 'GT' THEN 'Garnet'
WHEN stonetype = 'BER' THEN 'Beryl'
WHEN stonetype = 'TML' THEN 'Tourmaline'
WHEN stonetype = 'KO' THEN 'Kornerupine'
ELSE 'n/a'
END AS 'stonetype',
CASE
WHEN enhcode = 'H' THEN 'Heated'
WHEN enhcode = 'N' THEN 'Unheated'
ELSE 'n/a'
END AS 'enhcode'
FROM
stones
WHERE
wt >= 2.5
";
if(isset($_POST["minimum_wt"], $_POST["maximum_wt"]) && !empty($_POST["minimum_wt"]) && !empty($_POST["maximum_wt"])) {
$SQL .= "
AND wt BETWEEN '".$_POST["minimum_wt"]."' AND '".$_POST["maximum_wt"]."'
";
}
if(isset($_POST["shape"])) {
$shape_filter = implode("','", $_POST["shape"]);
$SQL .= "
AND stoneshape IN('".$shape_filter."')
";
}
if(isset($_POST["color"])) {
$color_filter = implode("','", $_POST["color"]);
$SQL .= "
AND stonecolor IN('".$color_filter."')
";
}
if(isset($_POST["enhancement"])) {
$enhancement_filter = implode("','", $_POST["enhancement"]);
$SQL .= "
AND enhcode IN('".$enhancement_filter."')
";
}
if(isset($_POST["matching"])) {
$matching_filter = implode("','", $_POST["matching"]);
$SQL .= "
AND pair IN('".$matching_filter."')
";
}
$SQL .= "
ORDER BY wt ASC
LIMIT
$offset,
$limit
";
$result = mysqli_query($db, $SQL);
$output = '';
if(isset($_POST["minimum_wt"], $_POST["maximum_wt"]) && !empty($_POST["minimum_wt"]) && !empty($_POST["maximum_wt"]) && isset($_POST["shape"]) && isset($_POST["color"]) && isset($_POST["enhancement"]) && isset($_POST["matching"])) {
if($row = mysqli_fetch_array($result)) {
foreach($result as $row) {
$output .= '
<div class="Stone">
<!-- landing page -->
<a href="#ItemPage" class="ItemLink" rel="modal:open" id="' . $row['number']. '">
<!-- image -->
<div class="StoneData StoneIMG"> <img src="../../../' . $row['image1'] . '"> </div>
<!-- weight -->
<div class="StoneData">' . $row['wt'] . 'Ct</div>
<!-- type -->
<div class="StoneData">' . $row['stonetype'] . '</div>
<!-- enhancement -->
<div class="StoneData">' . $row['enhcode'] . '</div>
<!-- dimensions -->
<div class="StoneData">' . $row['length'] . ' x ' . $row['width'] . '</div>
<!-- item number -->
<div class="StoneData"># ' . $row['number'] . '</div>
</a>
</div>
';
}
}
} else {
$output = '
<h1 class="Error">
<span class="mdi mdi-filter-remove mdi-48px"></span>
NO STONES MATCH THAT
</h1>
';
}
echo $output;
}
?>
My problem is when the user updates the filters my pagination jumps to the next page so not only will they not see the else statement on FilterData.php (which can obviously be very confusing for the user) but they will get a totally blank page, even when there are some results.
I imagine the solution to be resetting to the first page (of my pagination) every time the data updates. But for some reason I can't figure out how to do it. I tried changing line 52 of Filters.js to $('#pageno').val(0);, but that didn't seem to work as expected.
I know this is probably a very simple issue for you guys and i'm sort of embarrassed even asking but I've been trying to fix this since last Wednesday and still can't get it (i'm pretty new to php). Thank you so much for your time in advance!

How to open fancybox pop-up view images outside of an iframe which has an image gallery made in php?

I installed a php gallery and configured it and I finally could make it to run inside an iframe.But now when I click at an image, I want it to open that image pop-up view outside the iframe.imgGallery
<?php
if (isset($this->vars['file_list']))
{
$thumb_code['file'] = $this->getThumbCode("file");
foreach ($this->vars['file_list'] as $file)
{
$output = '';
$img_url = $this->genThumbURL($request, $file);
if ($this->settings['use_popup_image_viewer'] == true) {
$url = "?image=" . $request . $file['file'];
if ($this->settings['show_thumbs_under_viewer'] == true) {
$fancy_class = "fancybox-thumbs";
$fancy_attr = "data-fancybox-group=\"thumb\"";
} else {
$fancy_class = "fancybox";
$fancy_attr = "data-fancybox-group=\"gallery\"";
}
} else {
$url = '?view=' . $request . $file['file'];
$fancy_class = "";
$fancy_attr = "";
}
//<<URL>> = $url = ?view=folder/image.jpg
//<<FANCY_CLASS>> = $fancy_class = fancybox-thumbs (If left out fancybox will not work. Use inside class attribute on A tag)
//<<FANCY_ATTR>> = $fancy_attr = data-fancybox-group="gallery" (If left out fancybox will not work. Use on A tag)
//<<TITLE>> = $file['file'] = image.jpg
//<<THUMB_WIDTH>> = $this->settings['thumb_size_' . $this->vars['thumb_size']] = 125 (autodetect thumb size also)
//<<THUMB_HEIGHT>> = $this->settings['thumb_size_' . $this->vars['thumb_size']] = 125 (autodetect thumb size also)
//<<THUMB_LOCATION>> = $this->escapeString($img_url) = phppi/cache/folder/image_small.jpg (may also set to phppi/themes/gallery/themename/images/no_images.png if no image)
//<<THEME_LOCATION>> = $this->showThemeURL(1) = phppi/themes/gallery/themename
$replace_codes = array("<<URL>>",
"<<FANCY_CLASS>>",
"<<FANCY_ATTR>>",
"<<TITLE>>",
"<<THUMB_WIDTH>>",
"<<THUMB_HEIGHT>>",
"<<THUMB_LOCATION>>",
"<<THEME_LOCATION>>"
);
$replace_values = array($url,
$fancy_class,
$fancy_attr,
$file['file'],
$this->settings['thumb_size_' . $this->vars['thumb_size']],
$this->settings['thumb_size_' . $this->vars['thumb_size']],
$this->escapeString($img_url),
$this->showThemeURL(1)
);
echo str_replace($replace_codes, $replace_values, $thumb_code['file']);
}
}
echo "<div style=\"clear: both;\"></div>\n";
}
function showPrevFolderURL($format = 0)
{
//0 = Output url
//1 = Return url as string
if ($format == 0)
{
echo '?' . $this->vars['dir']['req']['parent'];
} else if ($format == 1) {
return '?' . $this->vars['dir']['req']['parent'];
}
}
function showPrevImageURL($format = 0)
{
//0 = Output url
//1 = Return url as string
if ($format == 0)
{
if ($this->settings['use_javascript_navigation'] == true)
{
echo 'javascript: phppi.go_prev_image();';
} else {
if (isset($this->vars['file_list'][$this->vars['previous_image_id']]['full_path']))
{
echo '?view=' . $this->vars['file_list'][$this->vars['previous_image_id']]['full_path'];
} else {
echo '';
}
}
} else if ($format == 1) {
if ($this->settings['use_javascript_navigation'] == true)
{
return 'javascript: phppi.go_prev_image();';
} else {
if (isset($this->vars['file_list'][$this->vars['previous_image_id']]['full_path']))
{
return '?view=' . $this->vars['file_list'][$this->vars['previous_image_id']]['full_path'];
} else {
return '';
}
}
}
}
function showNextImageURL($format = 0)
{
//0 = Output url
//1 = Return url as string
if ($format == 0)
{
if ($this->settings['use_javascript_navigation'] == true)
{
echo 'javascript: phppi.go_next_image();';
} else {
if (isset($this->vars['file_list'][$this->vars['next_image_id']]['full_path']))
{
echo '?view=' . $this->vars['file_list'][$this->vars['next_image_id']]['full_path'];
} else {
echo '';
}
}
} else if ($format == 1) {
if ($this->settings['use_javascript_navigation'] == true)
{
return 'javascript: phppi.go_next_image();';
} else {
if (isset($this->vars['file_list'][$this->vars['next_image_id']]['full_path']))
{
return '?view=' . $this->vars['file_list'][$this->vars['next_image_id']]['full_path'];
} else {
return '';
}
}
}
}
function showUpFolderURL($format = 0)
{
//0 = Output url
//1 = Return url as string
if ($format == 0)
{
echo '?' . $this->pathInfo($_GET['view'], 'dir_path');
} else if ($format == 1) {
return '?' . $this->pathInfo($_GET['view'], 'dir_path');
}
}
function showThemeURL($format = 0)
{
//0 = Output url
//1 = Return url as string
if ($format == 0)
{
echo 'phppi/themes/gallery/' . $this->settings['theme'] . '/' . $this->vars['theme_mode'] . '/';
} else if ($format == 1) {
return 'phppi/themes/gallery/' . $this->settings['theme'] . '/' . $this->vars['theme_mode'] . '/';
}
}
function showTitle($format = 0)
{
//0 = Output url
//1 = Return url as string
if ($format == 0)
{
echo $this->vars['page_title'];
} else if ($format == 1) {
return $this->vars['page_title'];
}
}
function showSiteName($format = 0)
{
//0 = Output name
//1 = Return name as string
if ($format == 0)
{
echo $this->settings['site_name'];
} else if ($format == 1) {
return $this->settings['site_name'];
}
}
function showLogo($format = 0)
{
//0 = Output img tag
//1 = Return img tag as string
if ($format == 0)
{
echo "<img id=\"page-logo\" src=\"" . $this->settings['page_title_logo'] . "\" alt=\"" . $this->settings['site_name'] . "\">";
} else if ($format == 1) {
return "<img id=\"page-logo\" src=\"" . $this->settings['page_title_logo'] . "\" alt=\"" . $this->settings['site_name'] . "\">";
}
}
function showNav($format = 0, $home = "", $prev = "", $sep = "", $mode = "")
{
//Mode:
//classic = Only show title and previous button
//new = Breadcrumb style, may take up most of the page if using a large folder tree
//auto = Depending on theme it may switch between the two depending on the screen size
//left empty = Set based on user settings
//$home = HTML to insert for home button
//$prev = HTML to insert for prev button
//$sep = HTML to insert for seperator
$output = "";
if ($mode == "") {
$mode = $this->settings['nav_menu_style'];
}
if ($mode == "auto" || $mode == "new") {
$new_output = "<ul><li class=\"nav-home\">" . $home . "</li>";
$url = "?";
if ($this->vars['dir']['req']['full'] !== "") {
$new_output .= "<li class=\"nav-sep\">" . $sep . "</li>";
$i = 1;
foreach ($this->vars['dir']['req']['split'] as $value) {
if ($i < (count($this->vars['dir']['req']['split']))) {
$url .= $value . "/";
$new_output .= "<li>" . $value . "</li>";
$new_output .= "<li class=\"nav-sep\">" . $sep . "</li>";
} else {
$new_output .= "<li class=\"nav-curr\"><div class=\"title\">" . $value . "</div></li>";
}
$i++;
}
}
$new_output .= "</ul>";
}
if ($mode == "auto" || $mode == "classic")
{
$url = "?";
if ($this->vars['dir']['req']['parent'] !== "") {
$i = 1;
foreach ($this->vars['dir']['req']['split'] as $value) {
if ($i < (count($this->vars['dir']['req']['split']))) {
$url .= $value . "/";
}
$i++;
}
$url = substr($url, 0, -1);
}
$classic_output = "<ul><li class=\"nav-prev\">" . $prev . "</li>";
if ($this->vars['dir']['req']['curr'] !== "") {
$classic_output .= "<li class=\"nav-sep\">" . $sep . "</li>";
$classic_output .= "<li class=\"nav-curr\"><div class=\"title\">" . $this->vars['dir']['req']['curr'] . "</div></li>";
}
$classic_output .= "</ul>";
}
if ($mode == "auto") {
$output .= "<div class=\"nav-menu-new\">" . $new_output . "</div>";
$output .= "<div class=\"nav-menu-classic\">" . $classic_output . "</div>";
} else if ($mode == "new") {
$output = $new_output;
} else if ($mode == "classic") {
$output = $classic_output;
}
//0 = Output nav
//1 = Return nav as string
if ($format == 0)
{
echo $output;
} else if ($format == 1) {
return $output;
}
}
function showPage()
{
require($this->showThemeURL(1) . 'pages/' . $this->vars['page_requested'] . '.php');
}
function resizedSize($width, $height, $return = 2)
{
//Returns width, height or an array of width and height for the thumbnail size of a full sized image
if ($width > $height)
{
$new_height = $this->settings['thumb_size_' . $this->vars['thumb_size']];
$new_width = $width * ($this->settings['thumb_size_' . $this->vars['thumb_size']] / $height);
} else if ($width < $height) {
$new_height = $height * ($this->settings['thumb_size_' . $this->vars['thumb_size']] / $width);
$new_width = $this->settings['thumb_size_' . $this->vars['thumb_size']];
} else if ($width == $height) {
$new_width = $this->settings['thumb_size_' . $this->vars['thumb_size']];
$new_height = $this->settings['thumb_size_' . $this->vars['thumb_size']];
}
if ($return == 0)
{
//Return width
return floor($new_width);
} else if ($return == 1) {
//Return height
return floor($new_height);
} else if ($return == 2) {
//Return array with width and height
return array(floor($new_width), floor($new_height));
}
}
function insertHeadInfo()
{
echo "
<!--
PHP Picture Index " . $this->vars['version'] . "
Created by: Brendan Ryan (http://www.pixelizm.com/)
Site: http://phppi.pixelizm.com/
Licence: GNU General Public License v3
http://www.gnu.org/licenses/
-->\n\n";
echo "<meta name=\"viewport\" content=\"width=device-width; initial-scale=1.0; user-scalable = no; maximum-scale=1.0;\">\n";
if (isset($_GET['view']) && !isset($this->vars['error'])) {
echo "<script type=\"text/javascript\" src=\"phppi/scripts/jquery/jquery.js\"></script>";
} elseif ($this->settings['use_popup_image_viewer'] == true) {
echo "<script type=\"text/javascript\" src=\"phppi/scripts/jquery/jquery.js\"></script>\n";
}
if (isset($_GET['view']) && !isset($this->vars['error']))
{
if ($this->settings['page_title_show_full_path'] == true) { $temp_title_full_path = '1'; } else { $temp_title_full_path = '0'; }
if ($this->settings['enable_hotkeys']) { $enable_hotkeys = 1; } else { $enable_hotkeys = 0; }
if ($this->settings['enable_up_hotkey']) { $enable_up_hotkey = 1; } else { $enable_up_hotkey = 0; }
echo "
<script type=\"text/javascript\" src=\"phppi/scripts/phppi_js.js\"></script>
<script type=\"text/javascript\">
$(document).ready(function() { phppi.initialize(); });
phppi.image_width = " . $this->vars['file_list'][$this->vars['current_image_id']]['data'][0] . ";
phppi.image_height = " . $this->vars['file_list'][$this->vars['current_image_id']]['data'][1] . ";
phppi.up_folder = '" . $this->escapeString($this->showUpFolderURL(1)) . "';
phppi.prev_image = '" . $this->escapeString($this->showPrevImageURL(1)) . "';
phppi.next_image = '" . $this->escapeString($this->showNextImageURL(1)) . "';
phppi.title_full_path = " . $temp_title_full_path . ";
phppi.enable_hotkeys = " . $enable_hotkeys . ";
phppi.enable_up_hotkey = " . $enable_up_hotkey . ";";
if ($this->settings['use_javascript_navigation'] == true)
{
$file_list = "";
$x = 0;
$dir = $this->pathInfo($_GET['view'], 'dir_path');
foreach($this->vars['file_list'] as $file) {
$file_list .= "['" . $this->escapeString($dir) . "/" . $this->escapeString($file['file']) . "', '" . $this->escapeString($file['file']) . "', " . $file['data'][0] . ", " . $file['data'][1] . "]";
if ($x < (count($this->vars['file_list']) - 1)) { $file_list .= ","; }
$x++;
}
echo "
phppi.site_name = '" . $this->settings['site_name'] . "';
phppi.page_title = '" . $this->vars['page_title'] . "';
phppi.current_file = " . $this->vars['current_image_id'] . ";
phppi.files = [" . $file_list . "];";
}
echo "</script>\n";
}
if ($this->settings['use_popup_image_viewer'] == true)
{
echo "<script type=\"text/javascript\" src=\"phppi/scripts/fancybox/jquery.fancybox.js\"></script>\n";
if ($this->settings['show_thumbs_under_viewer'] == true) { echo "<script type=\"text/javascript\" src=\"phppi/scripts/fancybox/jquery.fancybox-thumbs.js\"></script>\n"; }
if ($this->settings['enable_mousewheel'] == true) { echo "<script type=\"text/javascript\" src=\"phppi/scripts/fancybox/jquery.mousewheel-3.0.6.pack.js\"></script>\n"; }
if ($this->settings['show_thumbs_under_viewer'] == true) {
//Thumb Helper Version
echo "<script type=\"text/javascript\">
$(document).ready(function() {
$('.fancybox-thumbs').fancybox({
openEffect: '" . $this->settings['open_image_animation'] . "',
closeEffect: '" . $this->settings['close_image_animation'] . "',
prevEffect: '" . $this->settings['nextprev_image_animation'] . "',
nextEffect: '" . $this->settings['nextprev_image_animation'] . "',
closeBtn: false,
arrows: false,
nextClick: true,
helpers: {
thumbs: {
width: " . $this->settings['popup_thumb_size'] . ",
height: " . $this->settings['popup_thumb_size'] . "
}
}
});
});
</script>\n";
} else {
//Normal Version
echo "<script type=\"text/javascript\">
$(document).ready(function() {
$('.fancybox').fancybox({
openEffect: '" . $this->settings['open_image_animation'] . "',
closeEffect: '" . $this->settings['close_image_animation'] . "',
prevEffect: '" . $this->settings['nextprev_image_animation'] . "',
nextEffect: '" . $this->settings['nextprev_image_animation'] . "'
});
});
</script>\n";
}
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"phppi/scripts/fancybox/jquery.fancybox.css\">\n";
if ($this->settings['show_thumbs_under_viewer'] == true) { echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"phppi/scripts/fancybox/jquery.fancybox-thumbs.css\">\n"; }
}
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"phppi/css/global.css\">\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"phppi/themes/thumbnail/" . $this->settings['thumbnail_theme'] . "/style.css\">\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $this->showThemeURL(1) . "style.css\">\n";
}
function initialize()
{
//Debug Mode
if ($this->settings['debug_mode'] == true)
{
error_reporting(E_ALL);
ini_set('display_errors', '1');
}
ini_set('memory_limit', $this->settings['php_memory'] . 'M');
//Set Thumb Size if changed
if (isset($_POST['thumb_size'])) {
if ($_POST['thumb_size'] == 0) {
$this->setThumbSize('small');
} else if ($_POST['thumb_size'] == 1) {
$this->setThumbSize('medium');
} else if ($_POST['thumb_size'] == 2) {
$this->setThumbSize('large');
}
} else {
$this->setThumbSize(NULL);
}
//GZIP Compression
ini_set('zlib.output_compression', $this->settings['use_gzip_compression']);
ini_set('zlib.output_compression_level', $this->settings['gzip_compression_level']);
//Theme Mode
$this->setThemeMode();
if ($this->settings['allow_mobile_theme'] == true)
{
if (!is_file('phppi/themes/gallery/' . $this->settings['theme'] . '/' . $this->vars['theme_mode'] . '/template.php'))
{
$this->vars['theme_mode'] = 'standard';
}
} else {
$this->vars['theme_mode'] = 'standard';
}
//Load Variables
$this->loadVars();
//Load Blacklists/Whitelists
$this->loadLists();
//Display Content
if (isset($_GET['thumb']))
{
//Show thumbnail only
$this->genThumbnail($_GET['thumb']);
exit;
} else if (isset($_GET['image'])) {
//Show image
if ($this->checkExploit('/' . $_GET['image']) == true) {
$file_ext = strtolower($this->pathInfo($_GET['image'], 'file_ext'));
if ($file_ext == 'jpg' or $file_ext == 'jpeg')
{
$format = 'jpeg';
} else if ($file_ext == 'png') {
$format = 'png';
} else if ($file_ext == 'gif') {
$format = 'gif';
}
header("Content-length: " . filesize($this->vars['dir']['gallery'] . '/' . $_GET['image']));
header("Content-type: image/" . $format);
readfile($this->vars['dir']['gallery'] . '/' . $_GET['image']);
} else {
echo "File doesn't exist.";
}
exit;
} else if (isset($_GET['view'])) {
//Show full image view
$req_path = $this->pathInfo($_GET['view'], 'dir_path');
if ($req_path !== "") { $req_path = "/" . $req_path; }
if ($this->checkExploit($req_path) == true) {
if (!$this->getDir($req_path . '/'))
{
$this->vars['error'] = 'Folder doesn\'t exist';
$this->vars['page_title'] = 'Error';
$this->vars['page_requested'] = 'error';
$this->logs("access", "add", "Folder not found (/" . $_GET['view'] . ")");
} else if (!is_file($this->vars['dir']['gallery'] . '/' . $_GET['view'])) {
$this->vars['error'] = 'File doesn\'t exist';
$this->vars['page_title'] = 'Error';
$this->vars['page_requested'] = 'error';
$this->logs("access", "add", "File not found (/" . $_GET['view'] . ")");
} else {
for($i = 0; $i < count($this->vars['file_list']); $i++)
{
if ($this->vars['file_list'][$i]['file'] == $this->pathInfo($_GET['view'], 'full_file_name'))
{
$this->vars['current_image_id'] = $i;
$this->vars['previous_image_id'] = NULL;
$this->vars['next_image_id'] = NULL;
if ($i > 0)
{
$this->vars['previous_image_id'] = $i - 1;
}
if ($i < (count($this->vars['file_list']) - 1))
{
$this->vars['next_image_id'] = $i + 1;
}
break;
}
}
if ($this->settings['page_title_show_full_path'] == true) {
$this->vars['page_title'] = $this->settings['site_name'] . " - " . str_replace("/", " \ ", $_GET['view']);
} else {
$this->vars['page_title'] = $this->settings['site_name'] . " - " . $this->pathInfo($_GET['view'], 'full_file_name');
}
$this->vars['page_requested'] = 'image';
$this->logs("access", "add", "Viewed image (/" . $_GET['view'] . ")");
}
} else {
$this->vars['error'] = 'File doesn\'t exist';
$this->vars['page_title'] = 'Error';
$this->vars['page_requested'] = 'error';
$this->logs("access", "add", "Possible exploit attempt, blocked access (/" . $_GET['view'] . ")");
}
require('phppi/themes/gallery/' . $this->settings['theme'] . '/' . $this->vars['theme_mode'] . '/template.php');
if ($this->settings['debug_show_vars'] == true) { $this->outputVarsArray(); }
if ($this->settings['debug_show_settings'] == true) { $this->outputSettingsArray(); }
} else {
//Show folder view
if ($this->vars['dir']['req']['full'] == '')
{
$dir_req = "";
} else {
$dir_req = $this->vars['dir']['req']['full'] . '/';
}
if ($this->vars['dir']['req']['full'] == '' || $this->checkExploit('/' . $this->vars['dir']['req']['full']) == true) {
if (!$this->getDir($dir_req))
{
$this->vars['error'] = 'Folder doesn\'t exist';
$this->vars['page_title'] = 'Error';
$this->vars['page_requested'] = 'error';
$this->logs("access", "add", "Folder not found (/" . $dir_req . ")");
} else {
if ($this->settings['page_title_show_full_path'] == true) {
if ($this->vars['dir']['req']['full'] == "") { $sep = ""; } else { $sep = " - "; }
$this->vars['page_title'] = $this->settings['site_name'] . $sep . str_replace("/", " \ ", $this->vars['dir']['req']['full']);
} else {
if ($this->vars['dir']['req']['full'] == "") { $sep = ""; } else { $sep = " - "; }
$this->vars['page_title'] = $this->settings['site_name'] . $sep . $this->vars['dir']['req']['curr'];
}
$this->vars['page_requested'] = 'folder';
$this->logs("access", "add", "Viewed folder (/" . $dir_req . ")");
}
} else {
$this->vars['error'] = 'Folder doesn\'t exist';
$this->vars['page_title'] = 'Error';
$this->vars['page_requested'] = 'error';
$this->logs("access", "add", "Folder not found or exploit attempt, blocked access (/" . $dir_req . ")");
}
require('phppi/themes/gallery/' . $this->settings['theme'] . '/' . $this->vars['theme_mode'] . '/template.php');
if ($this->settings['debug_show_vars'] == true) { $this->outputVarsArray(); }
if ($this->settings['debug_show_settings'] == true) { $this->outputSettingsArray(); }
}
}
}
?>
How to add or turn this jQuery or Javascript code into php to modify this fancybox to open images outside of the iframe?
<script>
/* <![CDATA[ */
$(document).ready(function() {
$('.imagen').click(function(e){
e.preventDefault();
parent.$.fancybox([
{href:'img/sample-9.jpg', title: '01'},
{href:'img/sample-9.jpg', title: '02'},
{href:'img/sample-9.jpg', title: '03'}
],{
// href: this.href,
helpers: {
overlay: {
opacity: 0.3
} // overlay
//, buttons: {}
} // helpers
}); // fancybox
}); // click
//or in this way using another way or option
$('.image').click(function(e){
e.preventDefault();
parent.$.fancybox({
href: this.href,
width: 560,
height: 315,
type: 'iframe',
helpers: {
overlay: {
opacity: 0.3
} // overlay
} // helpers
}); // fancybox
}); // click
beforeClose: function() {
$(".fancybox-inner").unwrap();
},
helpers: {
overlay: {
opacity: 0.3
} // overlay
}
}); //fancybox
return false;
}); //click
}); // ready
/* ]]> */
</script>
This problem is similar to this example:Example Demo
I am in the iframed page 01 situation and I want to do something similar to
iframed page 02.
Your page inside <iframe> is limited to the shape of iframe. Period.
First what comes to my mind is this. In order to display something bigger than iframe you would have to have some script outside your iframe, and then have some communication between iframe contents and page with iframe (most likely with postMessage).
Other idea would be going with your gallery full screen with FullscreenAPI, and then you would have all screen to yourself. In case of gallery that could lead to some nice effect. Just remember, to be able to do that, <iframe> that displays your gallery has to has attribute allowfullscreen (no value needed).
In both cases you will need to be able to either add additional JavaScript outside iframe, or control how iframe is added to page. This is security measure so the contents of iframe will not abduct the parent page.

PHP - Sorting tables/ table filtering using jquery [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I am using the free code of tablefilter.free.fr and have adding this to my code but it does not get executed.
I have added the html and javascript into https://jsfiddle.net/koalyptus/eCqG3/ and it works fine but when i use my page -> http://mr-tipster.com/pages/newcard.php?venue=Southwell it does not render for some reason although the same html is output.
below is the full code i use on the page to create the tables and add the javascript.
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="../table/tablefilter.js"></script>
<?php
//show today's meeting name
if ($numrows > 0) {
echo '' . $entry . '';
} else {
echo '' . $entry . '';
}
$met1 = array_values($meeting);
if (array_shift($met1) == $entry && $venue =="" || $venue == $entry)
{
echo ''.$entry.'';
if ($venue =="")
{
$venue = array_shift($met1);
}
}
else
{
}
// pull the times for that meeting
$grabtracktimes = mysqli_query($db, 'SELECT Racetime,Going,distance, COUNT(*) c FROM tom_cards Where Track = "' . $venue . '" GROUP BY Racetime HAVING c > 1;');
$meetingtime = array();
echo "<br />";
while ($grabtodaystracktimes = mysqli_fetch_array($grabtracktimes)) {
$meetingtime[] = $grabtodaystracktimes['Racetime'];
}
$meetingtime1 = array_unique($meetingtime);
foreach ($meetingtime1 as $entrytime) {
if ($time == "") {
$time = array_shift(array_values($meetingtime1));
}
if (array_shift($meetingtime1) == $entrytime and $time == "" or $time == $entrytime) {
echo '' . $entrytime . '';
if ($time == "") {
$time = array_shift($meetingtime1);
}
} else {
echo '' . $entrytime . '';
}
}
echo "<br /><b>" . $venue . "(" . $time . ")</b>";
$sqltodaystrack = "";
$sqltodaystrack2 = mysqli_query($db, $sqltodaystrack );
$todaystrackleftorright = "";
$todaystrackspeed = "";
$todaystracksurface = "";
while ( $sqltodaystrack3 = mysqli_fetch_array($sqltodaystrack2)) {
$todaystrackleftorright = $sqltodaystrack3['Left_or_Right'];
$todaystrackspeed = $sqltodaystrack3['speed'];
$todaystracksurface = $sqltodaystrack3['surface'];
}
$sql = 'SELECT Race_Name,distance,going,surface FROM tom_cards Where Track ="' . $venue . '" and Racetime = "' . $time . '" group by Racetime ';
$horses2 = mysqli_query($db, $sql);
$first = true;
while ($todayhorse = mysqli_fetch_array($horses2)) {
if ($first == true) {
// do something
$first = false;
$todaysgoing = $todayhorse['going'];
$todaysdistance = miletofurlong($todayhorse['distance']);
echo "<br /><br /><b>" . $todayhorse['Race_Name'] . "</b>";
//add notes about the race course here
$sqlfortrack = 'SELECT notes,Handicaps, Non_Handicaps FROM RaceCourse Where Course ="' . $venue . '"';
$fortrack = mysqli_query($db, $sqlfortrack );
while ($fortrack2 = mysqli_fetch_array($fortrack)) {
echo "<br /><span style='font-size:11px'><b>Course Notes:</b> ".$fortrack2['notes']."</span><BR />";
//check if handicap or not and check for any course details
if (strpos($todayhorse['Race_Name'], 'Handicap') !== FALSE)
{
echo "<span style='font-size:11px'>".$fortrack2['Handicaps']."<span/>";
}
else
{
echo "<span style='font-size:11px'>".$fortrack2['Non_Handicaps']."</span>";
}
}
echo " <br /><br />Distance: <b>" . miletofurlong($todayhorse['distance']) . "f </b>(" . $todayhorse['distance'] . ") Going: <b>" . $todayhorse['going'] . "</b>";
$surface = trim($db->real_escape_string($todayhorse['surface']));
}
}
echo "</div>";
echo "<table id='table1' style='border:0px;margin-top:50px;text-align: center ;'>";
echo "<tr style='font-weight: bold;'><td>Horse</td><td>Form</td><td>History</td><td>OR/Class</td><td>MT Rating</td><td>Naps</td></tr>";
$sql = 'SELECT horse,rp,ts,Naps,`OR`,Class,Jockeys_Claim,Trainer,Track FROM tom_cards Where Track ="' . $venue . '" and Racetime = "' . $time . '"';
$horses2 = mysqli_query($db, $sql);
$loop = 0;
while ($todayhorse = mysqli_fetch_array($horses2)) {
$placed = "";
$data = "";
$horse = trim($todayhorse['horse']);
$jockeys = $todayhorse['Jockeys_Claim'];
$trainer = $todayhorse['Trainer'];
$class = $todayhorse['Class'];
$or = $todayhorse['OR'];
$rp = $todayhorse['rp'];
$ts = $todayhorse['ts'];
$naps = $todayhorse['Naps'];
if ($surface == "Turf") {
$win = 0;
$runs = 0;
$place = 0;
$horsesplaced = ;
$check = "no";
while ($pasthorse = mysqli_fetch_array($horsesplaced)) {
$dbDate = $pasthorse['Date'];
$placeddata = intval($pasthorse['Place']);
//add 1 to runs everyloop to show how many runs they have had
$runs = $runs + 1;
//if the horse has won a race then mark it red and add 1 point to the win tally
if ($placeddata == 1) {
$placed .= "<b><span style='color:#8DB600'>" . $pasthorse['Place'] . "</span></b>";
$win = $win + 1;
} else {
//if the horse was placed higher then 9th just add 0
if (intval($pasthorse['Place']) > 9) {
$pasthorse['Place'] = 0;
}
//echo all the places
if ($pasthorse['Place'] == "PU") {
$pasthorse['Place'] = str_replace($pasthorse['Place'], 'PU', '<b>P</b>');
}
if ($pasthorse['Place'] == "F") {
$pasthorse['Place'] = str_replace($pasthorse['Place'], 'F', '<b>F</b>');
}
if ($pasthorse['Place'] == "2" or $pasthorse['Place'] == "3") {
$pasthorse['Place'] = str_replace($pasthorse['Place'], $pasthorse['Place'], "<span style='color:#8DB600'>" . $pasthorse['Place'] . "</span>");
}
$placed .= $pasthorse['Place'];
// if runners are greater then 4 and less the 8 only 2 to place
if ($pasthorse['Runners'] < 4 and $pasthorse['Runners'] > 8) {
if ($pasthorse['Place'] == 2) {
$place = $place + 1;
}
}
if ($pasthorse['Runners'] < 7 and $pasthorse['Runners'] > 16) {
if ($pasthorse['Place'] == 2 or $pasthorse['Place'] == 3) {
$place = $place + 1;
}
}
if ($pasthorse['Runners'] < 15) {
if ($pasthorse['Place'] == 2 or $pasthorse['Place'] == 3 or $pasthorse['Place'] == 4) {
$place = $place + 1;
}
}
}
}
} elseif ($surface == "AW") {
$win = 0;
$runs = 0;
$place = 0;
$horsesplaced = ;
while ($pasthorse = mysqli_fetch_array($horsesplaced)) {
$placeddata = intval($pasthorse['Place']);
//add 1 to runs everyloop to show how many runs they have had
$runs = $runs + 1;
//if the horse has won a race then mark it red and add 1 point to the win tally
if ($placeddata == 1) {
$placed .= "<b><span style='color:red'>" . $pasthorse['Place'] . "</span></b>";
$win = $win + 1;
} else {
//if the horse was placed higher then 9th just add 0
if (intval($pasthorse['Place']) > 9) {
$pasthorse['Place'] = 0;
}
//echo all the places
$placed .= $pasthorse['Place'];
// if runners are greater then 4 and less the 8 only 2 to place
if ($pasthorse['Runners'] < 4 and $pasthorse['Runners'] > 8) {
if ($pasthorse['Place'] == 2) {
$place = $place + 1;
}
}
if ($pasthorse['Runners'] < 7 and $pasthorse['Runners'] > 16) {
if ($pasthorse['Place'] == 2 or $pasthorse['Place'] == 3) {
$place = $place + 1;
}
}
if ($pasthorse['Runners'] < 15) {
if ($pasthorse['Place'] == 2 or $pasthorse['Place'] == 3 or $pasthorse['Place'] == 4) {
$place = $place + 1;
}
}
}
}
}
$winner = "";
$placed1 = "";
if ($runs != 0) {
$winner = "(" . round(($win / $runs) * 100) . "%) ";
$placed1 = "(" . round((($place + $win) / $runs) * 100) . "%) ";
}
$thetrack = horseontrack($horse, $venue, $db);
list($corseruns, $corsewins, $corseplace) = explode("/", $thetrack);
$sqlhorses = "SELECT distance,Place,Runners FROM `horsesrp` WHERE `Horse` = '" . $horse . "' order by distance + 0,
substring_index(distance, 'm', -1) + 0";
$horseplaced = mysqli_query($db, $sqlhorses);
$data = "";
$dataleftorright = "";
$dataspeed = "";
$datasurface = "";
$storage = array();
$storetrackdirection = array();
$storetrackdirectionsurface= array();
$storetrackspeed= array();
while ($pasthorse = mysqli_fetch_array($horseplaced)) {
// check to see if its distance is that of today
$placetotals = 0;
$wintotals = 0;
$test = "";
$placeddata = intval($pasthorse['Place']);
if ($placeddata == 1) {
} else {
if ($pasthorse['Runners'] > 4 and $pasthorse['Runners'] < 8) {
$test = "--between 5 and 7--" . $pasthorse['Place'];
if ($pasthorse['Place'] == 2) {
$placetotals = 1;
}
}
if ($pasthorse['Runners'] > 7 and $pasthorse['Runners'] < 16) {
$test = "--Between 8 and 15--" . $pasthorse['Place'];
if ($pasthorse['Place'] == 2 or $pasthorse['Place'] == 3) {
$placetotals = 1;
}
}
if ($pasthorse['Runners'] > 15) {
$test = "over 15" . $pasthorse['Place'];
if ($pasthorse['Place'] == 2 or $pasthorse['Place'] == 3 or $pasthorse['Place'] == 4) {
$placetotals = 1;
}
}
}
// if the distance is the same
// Take this outside of the if statements
$mtfl = miletofurlong($pasthorse['distance']);
if ($mtfl == $todaysdistance) {
$Horsedist = "<b><span style='color:#ff4500 '>" . $mtfl . "f</span></b>";
} elseif (($mtfl >= $todaysdistance - 1) && ($mtfl <= $todaysdistance + 1)) {
// You don't need to check for equality here - if you get here it is because
// the values are not equal
$Horsedist = "<b><span style='color:#8DB600'>" . $mtfl . "f</span></b>";
} else {
$Horsedist = $mtfl . "f";
}
if (!isset($storage[$Horsedist])) {
$storage[$Horsedist] = array(
"win" => 0,
"placed" => 0,
"raced" => 0
);
}
// Then increment if required
// $data .= "<span style='font-size:10.5px'>".$Horsedist. " -Won:".$wintotals. " Placed:".$placetotals." </span><br />";
}
$sqlhorsesgoing = "SELECT going,Place,Runners FROM `horsesrp` WHERE `Horse` = '" . $horse . "' order by going";
$horseplacedgoing = mysqli_query($db, $sqlhorsesgoing);
$datagoing = "";
$storagegoing = array();
while ($pasthorsegoing = mysqli_fetch_array($horseplacedgoing)) {
// check to see if its going is that of today
$placeddatagoing = intval($pasthorsegoing['Place']);
if ($placeddatagoing == 1) {
} else {
if ($pasthorsegoing['Runners'] > 4 and $pasthorsegoing['Runners'] < 8) {
if ($pasthorsegoing['Place'] == 2) {
$placetotalsgoing = 1;
}
}
if ($pasthorsegoing['Runners'] > 7 and $pasthorsegoing['Runners'] < 16) {
if ($pasthorsegoing['Place'] == 2 or $pasthorsegoing['Place'] == 3) {
$placetotalsgoing = 1;
}
}
if ($pasthorsegoing['Runners'] > 15) {
if ($pasthorsegoing['Place'] == 2 or $pasthorsegoing['Place'] == 3 or $pasthorsegoing['Place'] == 4) {
$placetotalsgoing = 1;
}
}
}
// if the going is the same
// Take this outside of the if statements
$mtfl1 = $pasthorsegoing['going'];
if ($mtfl1 == $todaysgoing) {
$Horsegoing = "<b><span style='color:#ff4500 '>" . $mtfl1 . "</span></b>";
} else {
$Horsegoing = $mtfl1;
}
if (!isset($storagegoing[$Horsegoing])) {
$storagegoing[$Horsegoing] = array(
"win" => 0,
"placed" => 0,
"raced" => 0
);
}
// Then increment if required
}
$data = "<table class='tg' align='center' style='font-size:10.5px;'><tr><th style='padding-right:5px;'></th><th style='padding-right:5px;'> Runs </th><th style='padding-right:5px;'> Wins </th><th style='padding-right:5px;'> Placed </th></tr>";
foreach ($storage as $pony => $tab) {
// $data .= "<span style='font-size:10.5px'>".$Horsedist. " -Won:".$wintotals. " Placed:".$placetotals." </span><br />";
if ($tab["win"] !== 0) {
$distancewinners = "<b><span style='color:#ff4500 '>" . $tab["win"] . "</span></b>";
} else {
$distancewinners = $tab["win"];
}
if ($tab["placed"] !== 0) {
$distanceplace = "<b><span style='color:#ff4500 '>" . $tab["placed"] . "</span></b>";
} else {
$distanceplace = $tab["placed"];
}
}
$data .= "</table>";
foreach ($storagegoing as $ponygoing => $tabgoing) {
if ($tabgoing["win"] !== 0) {
$distancewinners = "<b><span style='color:#ff4500 '>" . $tabgoing["win"] . "</span></b>";
} else {
$distancewinners = $tabgoing["win"];
}
if ($tabgoing["placed"] !== 0) {
$distanceplace = "<b><span style='color:#ff4500 '>" . $tabgoing["placed"] . "</span></b>";
} else {
$distanceplace = $tabgoing["placed"];
}
//work out which courses the horse has ran at
$horseplacedtracks = "SELECT track,Place,Runners FROM `horsesrp` WHERE `Horse` = '" . $horse . "'";
$horseplacedtracks2 = mysqli_query($db, $horseplacedtracks );
$track ="";
$leftorright = "";
$surface = "";
$speed = "";
while ($pasthorsetracks = mysqli_fetch_array($horseplacedtracks2 ))
{
//remove (aw) and get the track name
$track = trim(str_replace("(AW)", "", $pasthorsetracks['track']));
//is the track left or right??
// check to see if its going is that of today
$placetotalstrack = 0;
$wintotalstrack = 0;
$placeddatatrack = intval($pasthorsetracks['Place']);
if ($placeddatatrack == 1) {
$placetotalstrack = 1;
$wintotalstrack = 1;
} else {
if ($pasthorsetracks['Runners'] > 4 and $pasthorsetracks['Runners'] < 8) {
if ($pasthorsetracks['Place'] == 2) {
$placetotalstrack = 1;
}
}
if ($pasthorsetracks['Runners'] > 7 and $pasthorsetracks['Runners'] < 16) {
if ($pasthorsetracks['Place'] == 2 or $pasthorsetracks['Place'] == 3) {
$placetotalstrack = 1;
}
}
if ($pasthorsetracks['Runners'] > 15) {
if ($pasthorsetracks['Place'] == 2 or $pasthorsetracks['Place'] == 3 or $pasthorsetracks['Place'] == 4) {
$placetotalstrack = 1;
}
}
}
// check the track against the database and asign left or right
$grabtrackdetails = "SELECT Left_or_Right FROM `RaceCourse` WHERE `Course` = '" . $track . "'";
$grabtrackdetails2 = mysqli_query($db, $grabtrackdetails );
while ($pastgrabtrackdetails = mysqli_fetch_array($grabtrackdetails2 ))
{
$leftorright = $pastgrabtrackdetails['Left_or_Right'];
/////////////////////////////////////////////////////////////////////////////////////
if (!isset($storetrackdirection[$leftorright])) {
$storetrackdirection[$leftorright] = array(
"win" => 0,
"placed" => 0,
"raced" => 0
);
}
// Then increment if required
$storetrackdirection[$leftorright]["win"] += $wintotalstrack;
$storetrackdirection[$leftorright]["placed"] += $placetotalstrack;
$storetrackdirection[$leftorright]["raced"] += 1;
}
// check the track against the database and asign left or right
$grabtrackdetailssurface = "SELECT surface FROM `RaceCourse` WHERE `Course` = '" . $track . "'";
$grabtrackdetailssurface2 = mysqli_query($db, $grabtrackdetailssurface );
while ($pastgrabtrackdetailssurface = mysqli_fetch_array($grabtrackdetailssurface2 ))
{
$surface = $pastgrabtrackdetailssurface['surface'];
if ($surface == "")
{
$surface = "Mix";
}
/////////////////////////////////////////////////////////////////////////////////////
if (!isset($storetrackdirectionsurface[$surface])) {
$storetrackdirectionsurface[$surface] = array(
"win" => 0,
"placed" => 0,
"raced" => 0
);
}
// Then increment if required
$storetrackdirectionsurface[$surface]["win"] += $wintotalstrack;
$storetrackdirectionsurface[$surface]["placed"] += $placetotalstrack;
$storetrackdirectionsurface[$surface]["raced"] += 1;
}
$horsehistory = "SELECT Date,track,Class,Distance,going,Place,Jockeys_claim,`OR`,Runners FROM `horsesrp` WHERE `Horse` = '" . $horse . "' order by Date DESC";
$horsehistory2 = mysqli_query($db, $horsehistory );
$horseshistoryget = "<br />";
?>
<script type="text/javascript">
var tf<?php echo $loop; ?> = setFilterGrid("loop<?php echo $loop; ?>");
</script>
<?
$horseshistoryget .= "<table id='loop".$loop."' class='mytable' align='center' style='font-size:10.5px;'><tr><th style='padding-right:5px;'></th><th style='padding-right:5px;'> Course </th><th style='padding-right:5px;'> Class</th><th style='padding-right:5px;'> Distance </th><th style='padding-right:5px;'> Going</th><th style='padding-right:5px;'> Outcome </th><th style='padding-right:5px;'> Jockey </th><th style='padding-right:5px;'> OR </th></tr>";
while ($gethorsehistory = mysqli_fetch_array($horsehistory2 ))
{
//$horseshistoryget .= "<tr style='height:18px; border-top:1pt solid black; border-bottom:0pt solid black;'><td style='border-top:1pt solid black; border-bottom:0pt solid black;'>" .$gethorsehistory["Date"] . "</td><td style='border-top:1pt solid black; border-bottom:0pt solid black;'>" . $gethorsehistory["Track"] . "</td><td style='border-top:1pt solid black; border-bottom:0pt solid black;'>" . $gethorsehistory["Class"] . "</td><td style='border-top:1pt solid black; border-bottom:0pt solid black;'>" . $gethorsehistory["Distance"] . "</td><td style='border-top:1pt solid black; border-bottom:0pt solid black;'>" . $gethorsehistory["Place"] . "</td><td style='border-top:1pt solid black; border-bottom:0pt solid black;'>" . $gethorsehistory["Jockeys_claim"] . "</td><td style='border-top:1pt solid black; border-bottom:0pt solid black;'>" . $gethorsehistory["`OR`"] . "</td></tr>";
$timestamp = strtotime($gethorsehistory["Date"]);
$newDate = date('d.m.y', $timestamp);
// check if the value is the same as today and bold it
$horseshistoryget .= "<tr><td>". $newDate. "</td>";
//check what todays course speed and surface is like
$todayscourseprofile = "SELECT speed,surface from RaceCourse where course = '".$venue."' ";
$todayscourseprofile2 = mysqli_query($db, $todayscourseprofile );
$todayscoursespeed = "" ;
$todayscoursesurface = "";
while ($gettodayscourseprofile = mysqli_fetch_array($todayscourseprofile2 ))
{
$todayscoursespeed = $gettodayscourseprofile["speed"] ;
$todayscoursesurface = $gettodayscourseprofile ["surface"];
}
//check if venue has the same profile as this one
$trackprofie = trim(str_replace("(AW)", "", $gethorsehistory["track"]));
$allcourseprofile = "SELECT speed, surface from RaceCourse where course = '".$trackprofie."' ";
$allcourseprofile2 = mysqli_query($db, $allcourseprofile );
while ($getallcourseprofile = mysqli_fetch_array($allcourseprofile2 ))
{
$allcoursespeed = "" ;
$allcoursesurface = "";
$allcoursespeed = $getallcourseprofile["speed"] ;
$allcoursesurface = $getallcourseprofile ["surface"];
}
//if they match colour them
if($todayscoursespeed == $allcoursespeed and $allcoursesurface == $todayscoursesurface )
{
if ($todayscoursespeed <> "" and $todayscoursesurface <> "")
{
$showtrack = "<span style='color:#336600 '>".$gethorsehistory["track"]."</span>";
}
else
{
$showtrack = $gethorsehistory["track"];
}
}
elseif ($todayscoursespeed == $allcoursespeed)
{
if ($todayscoursespeed <> "")
{
$showtrack = "<span style='color:#996600 '>".$gethorsehistory["track"]."</span>";
}
else
{
$showtrack = $gethorsehistory["track"];
}
}
elseif($todayscoursesurface == $allcoursesurface)
{
if ($todayscoursesurface <> "")
{
$showtrack = "<span style='color:#CC3300 '>".$gethorsehistory["track"]."</span>";
}
else
{
$showtrack = $gethorsehistory["track"];
}
}
else
{
$showtrack = $gethorsehistory["track"];
}
if ($gethorsehistory["track"] == $venue)
{
$horseshistoryget .= "<td><b>" . $showtrack. "</b></td>";
}
else{
$horseshistoryget .= "<td>" . $showtrack."</td>";
}
if ($gethorsehistory["Class"] == "Class".$class)
{
$horseshistoryget .= "<td><b>" . $gethorsehistory["Class"] . "</b></td>";
}
else
{
$horseshistoryget .= "<td>" . $gethorsehistory["Class"] . "</td>";
}
if (miletofurlong($gethorsehistory["Distance"]) == $todaysdistance)
{
$horseshistoryget .= "<td><b>" . miletofurlong($gethorsehistory["Distance"]). "f" . "</b></td>";
}
else
{
$horseshistoryget .= "<td>" . miletofurlong($gethorsehistory["Distance"]). "f" . "</td>";
}
if ($gethorsehistory["going"] == $todaysgoing)
{
$horseshistoryget .= "<td><b>" . $gethorsehistory["going"] . "</b></td>";
}
else{
$horseshistoryget .= "<td>" .$gethorsehistory["going"] . "</td>";
}
if ($gethorsehistory["Place"] == 1){
$pastplace = "<b><span style='color:#ff4500 '>".$gethorsehistory["Place"]."</span></b>";
}
else{
$pastplace = $gethorsehistory["Place"];
}
$horseshistoryget .= "<td>" . $pastplace ."/". $gethorsehistory["Runners"]. "</td>";
if ($gethorsehistory["Jockeys_claim"] == $jockeys)
{
$horseshistoryget .= "<td><b>" .$gethorsehistory["Jockeys_claim"]. "</b></td>";
}
else{
$horseshistoryget .= "<td>" . $gethorsehistory["Jockeys_claim"] . "</td>";
}
$horseshistoryget .= "<td>" .$t1. $gethorsehistory["OR"] .$t2. "</td></tr>";
}
$horseshistoryget .= "</table><br />";
//does the jockey only have one ride today???
echo "<tr valign='top'><td >";
echo "<b><span style='font-size:12px'> " . $horse . "</span></b> <sup><span style='font-size:10px;color:gray'><abbr title='Days Since Last Race'>" . horselastrace($horse, $db) . "</abbr> </span><b><span style='font-size:10px;color:red'><abbr title='Beaten Favourite'>" . horsebeatenfav($horse, $db) . "</abbr></span></sup></b>
<br /><span style='font-size:10.5px'><abbr title='Jockey'>J: " . $jockeys . "</abbr><abbr title='Jockey Win rate last 4 months'> (" . round(howhotisjockey($jockeys, $db)) . "%)</abbr> " . " <abbr title='Jockey Win rate on horse'>(" . round(howhotisjockeyonhorse($jockeys, $db, $horse)) . "%)</abbr><abbr title='Jockey rides today'> " . jockeyridestoday($jockeys, $db) . "</abbr>
<br /><abbr title='Trainer'> T: " . $trainer . "</abbr> <abbr title='Trainer Win rate last 4 months'>(" . round(howhotistrainer($trainer, $db)) . "%)</abbr> <abbr title='Trainers horses out today'> " . trainersridestoday($trainer, $db) . "</abbr> </span></td>";
echo "<td ><span style='font-size:11px'><abbr title='P = Pulled Up , F = Fell'> " . $placed . "</abbr></span> <span style='font-size:10.5px'> <abbr title='Win Percent'> " . $winner . "</abbr> <abbr title='Place Percent'>" . $placed1 . "</abbr></span> </td>";
// echo "<td ><span style='font-size:11px'>".$dataleftorright.$dataspeed.$datasurface."</span></td>";
// echo "<td >" . $data . "<br /></td>";
// echo "<td >" . $datagoing . "<br /></td>";
echo "<td >".$horseshistoryget."</td>";
echo "<td ><span style='font-size:11px'><abbr title='class and highest winning OR'> " . classtop2($horse, $db, $or, $class) . "</abbr></span> </td>";
echo "<td ><span style='font-size:11px'><abbr title='Mr-Tipster speed rating'> " . round((($rp + $ts) / 2)) . "</abbr> </span></td>";
echo "<td ><span style='font-size:11px'>" . $naps . "</span></td>";
echo "</tr>";
$loop = $loop + 1;
}
?>
</table>
</div>
</body>
</html>

How to change onhover list show/close in Magento Community

I have a minor problem.
Left side navigation menu toggle <--- website link - see left category navigation.
As you see in the link above, this is a left side navigation with toggle option. When clicking on the + sign the submenu gets unfolded and the + sign becomes a - sign, when clicking the - sign it gets back to normal.
The title on the left side is a link, when clicking on the title on the left it gets be directly ex. to the Fast Food category. However, I would like the title to have the same option as the +/- sign - and removing the link class.
The HTML code is:
<div class="block block-side-nav-container">
<div class="block-title">
<strong><span><?php echo $this->__('Categories') ?></span></strong>
</div>
<div class="block-content">
<div class="side-nav">
<ul id="category-treeview" class="treeview-side treeview">
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php echo $this->drawItem($_category) ?>
<?php endforeach ?>
</ul>
</div>
</div>
I might think that the code is a php language, please see below:
protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false,
$isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
{
if (!$category->getIsActive()) {
return '';
}
$html = array();
// get all children
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = (array)$category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = ($children && $childrenCount);
// select active children
$activeChildren = array();
foreach ($children as $child) {
if ($child->getIsActive()) {
$activeChildren[] = $child;
}
}
$activeChildrenCount = count($activeChildren);
$hasActiveChildren = ($activeChildrenCount > 0);
// prepare list item html classes
$classes = array();
$classes[] = 'level' . $level;
$classes[] = 'nav-' . $this->_getItemPosition($level);
if ($this->isCategoryActive($category)) {
$classes[] = 'active';
}
$linkClass = '';
if ($isOutermost && $outermostItemClass) {
$classes[] = $outermostItemClass;
$linkClass = ' class="'.$outermostItemClass.'"';
}
if ($isFirst) {
$classes[] = 'first';
}
if ($isLast) {
$classes[] = 'last';
}
if ($hasActiveChildren) {
$classes[] = 'parent';
}
// prepare list item attributes
$attributes = array();
if (count($classes) > 0) {
$attributes['class'] = implode(' ', $classes);
}
if ($hasActiveChildren && !$noEventAttributes) {
$attributes['onmouseover'] = 'toggleMenu(this,1)';
$attributes['onmouseout'] = 'toggleMenu(this,0)';
}
// assemble list item with attributes
$htmlLi = '<li';
foreach ($attributes as $attrName => $attrValue) {
$htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\"', $attrValue) . '"';
}
$htmlLi .= '>';
$html[] = $htmlLi;
$html[] = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>';
$html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
$html[] = '</a>';
// render children
$htmlChildren = '';
$j = 0;
foreach ($activeChildren as $child) {
$htmlChildren .= $this->_renderCategoryMenuItemHtml(
$child,
($level + 1),
($j == $activeChildrenCount - 1),
($j == 0),
false,
$outermostItemClass,
$childrenWrapClass,
$noEventAttributes
);
$j++;
}
if (!empty($htmlChildren)) {
if ($childrenWrapClass) {
$html[] = '<div class="' . $childrenWrapClass . '">';
}
$html[] = '<ul class="level' . $level . '">';
$html[] = $htmlChildren;
$html[] = '</ul>';
if ($childrenWrapClass) {
$html[] = '</div>';
}
}
$html[] = '</li>';
$html = implode("\n", $html);
return $html;
}
Please help.
Thank you!
You could fix this with jQuery.
All you have to do is add a slideToggle function to your menutitle.
First be sure to include jQuery in your site
Create a js file for little js fixes (i usually call it customjs.js) and include from the footer of your site
Add the following jQuery
$(".block-title").click(function(){
$(".block-content").slideToggle(); //SLIDE TOGGLE FOR SLIDING UP AND DOWN
return false; // PREVENTS LINK FROM WORKING
})
Check jsfiddle.net/pTg68/17/ for an example
Cheerz
Firstly find what the function is called, I would imagine it look something like this:
var menu = "closed";
function toggleMenu(){
if(menu = "closed"){
openTree();
}else{
closeTree();
}
}
function openTree(){
//code to open the menu
};
function closeTree(){
//code to close the menu
};
And all you would do is change the link from each category from
Fast Food
to
Fast Food

undefined error when iterating over json list

i got this code that keep on returning undefined msg instead of the expected html.
Purpose of function:
the purpose of the below function is to return notifications in away similar to fb one's. the code is working fine. but there's something wrong with the getJSON part that i couldn't figure out. so instead of returning "clonex1 likes your post" i get undefined.
the code
function buzzme()
{
jQuery('#cnumber').removeClass();
jQuery('#cnumber').empty();
jQuery('#floating_box').toggle();
var nHeader = '<div id="floating_box" class="fb">' +
'<div id="header"><span id="htext">Notifications</span></div>' +
'<div id="int">' +
'<div id="bodyx">' +
'<ul>';
var nFooter = '</ul>' +
'<div class="jfooter">' +
'See all notifications' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
var nContent;
jQuery.getJSON('notifications.php', {'n':1,'dht':3692}, function(response){
jQuery.each(response, function(i, nt2){
nContent += '<li id="lix">sdfsdfsd'+nt2.img+' '+nt2.notifier+'</li>';
})
});
alert(nContent);
var nFinal = nHeader+nContent+nFooter;
if (!jQuery('#floating_box').length) {
jQuery('body').append(nFinal);
}
}
notifications.php - setUpFlayout(); and setUpJSONList()
function setUpFlyout() {
$notify = new se_notify();
$data2 = $notify->notify_summary();
$trk = 0;
if($data2['total'] >= 1) {
for($i = 0; $ $i <= $data2['total']; $i++) {
$nid = $data2['notifys'][$i]['notify_id'];
$im = $data2['notifys'][$i]['notify_icon'];
$img = "<img src='./images/icons/$im' />";
$notifier = $data2['notifys'][$i]['notify_text'][0];
$atype = $data2['notifys'][$i]['notifytype_id'];
$url = '';
$url2 = $data2['notifys'][$i]['notify_url'];
if($atype == 1) {
$url = ' has sent you friend <a href='.$url2.'>request</a>';
}
$trk++;
if($data2['total'] >= 2) {
$ret_arr = '';
if($i == 0) {
$ret_arr = '[';
}
$ret_arr = $ret_arr.setUpJSONList($data2['total'], $nid, $img, $notifier, $url, $trk);
if($i == $data2['total']-1) {
$ret_arr = $ret_arr.']';
}
echo '';
} else if($data2['total'] == 1){
//$ret_arr = '[{"dh3":"'.$data2['total'].'","nid":"'.$nid.'", "img":"'.$img.'","notifier":"'.$notifier.'","url":"'.$url.'"}]';
$ret_arr = '';
echo $ret_arr;
}
if($i == ($data2['total']-1))
break;
}
}
}
setUpJSONList();
function setUpJSONList($total, $nid, $img, $notifier, $url, $track) {
$comma = ',';
$lp = '';
$rp = ']';
$result = '';
if($track == $total) {
$result = '{"pos":"'.$track.'","dh3":"'.$total.'","nid":"'.$nid.'","img":"'.$img.'","notifier":"'.$notifier.'", "url":"'.$url.'"}';
} else {
$result = '{"pos":"'.$track.'","dh3":"'.$total.'","nid":"'.$nid.'","img":"'.$img.'","notifier":"'.$notifier.'", "url":"'.$url.'"},';
}
return $result;
}
thanks
Your usage of nContent after getJSON might be undefined since getJSON is asynchronous and would not have completed initializing nContent. You need to move the code using nContent inside the callback of getJSON.
jQuery.getJSON('notifications.php', {'n':1,'dht':3692}, function(response){
jQuery.each(response, function(i, nt2){
nContent += '<li id="lix">sdfsdfsd'+nt2.img+' '+nt2.notifier+'</li>';
})
alert(nContent);
var nFinal = nHeader+nContent+nFooter;
if (!jQuery('#floating_box').length) {
jQuery('body').append(nFinal);
}
});

Categories