Skip to content

Instantly share code, notes, and snippets.

.input_tiny {
width: 50px;
}
.input_small {
width: 100px;
}
.input_medium {
width: 150px;
jQuery.fn.removeClassExcept = function (val) {
return this.each(function (index, el) {
var keep = val.split(" "), // list we'd like to keep
reAdd = [], // ones that should be re-added if found
$el = $(el); // element we're working on
// look for which we re-add (based on them already existing)
for (var c = 0; c < keep.length; c++){
if ($el.hasClass(keep[c])) reAdd.push(keep[c]);
}
<video autoplay="autoplay" loop="loop" width="400" height="300">
<source src="video.mp4" type="video/mp4" />
<img src="video.gif" width="400" height="300" />
</video>
<?php $terms = get_the_terms( $post->ID, 'taxonomyname' ); if ( $terms && ! is_wp_error( $terms ) ) : $taxname = array();?>
<ul>
<?foreach ( $terms as $term ): ?>
<li><?php echo $term->name; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php
$current_page = 'contact';
?>
<?php
if($current_page == 'contact') {
} else {
}
<?php
if (stripos($_SERVER['REQUEST_URI'], 'contact.php')){
}
else{
}
@Vernonmac
Vernonmac / li-to-text.js
Created November 3, 2015 14:59
Li to text
var lijst = $('.message li').map(function(){
return $(this).text();
}).get();
var newHTML = [];
for (var i = 0; i < lijst.length; i++) {
newHTML.push('' + lijst[i] + '. ');
}
$("div").html(newHTML.join(""));
<? $sizetext = 'available sizes:'; ?>
<?php if (36 == $_product->getAttributeSetId()) { //if has attribute set id?>
<?php
$sizes = array(); if($_product->isConfigurable()){ $allProducts = $_product->getTypeInstance(true)->getUsedProducts(null, $_product); foreach ($allProducts as $subproduct) { if ($subproduct->isSaleable() && floor($subproduct->getStockItem()->getQty()) > 0 ) { $sizes[] = $subproduct->getAttributeText('SMLXL');
}
}
if($sizes) { ?>

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
@Vernonmac
Vernonmac / magento-relatedproducts.php
Created May 5, 2015 04:20
magento related products
<?php if($_relatedProducts = $_product->getRelatedProductCollection()): ?>
<div class="topproducts_containter">
<?php foreach ($_relatedProducts as $_item): ?>
<?php $_item = Mage::getModel('catalog/product')->load($_item->getId()); ?>
<div class="floats">