Skip to content

Instantly share code, notes, and snippets.

View dannevang's full-sized avatar

Mathias Dannevang dannevang

View GitHub Profile
@dannevang
dannevang / showChunk
Created May 15, 2014 23:18
Show MODX chunk based on usergroup membership
<?php
/* ShowChunk snippet : Credit: Bob Ray */
$subChunks = explode(',', $scriptProperties['subscriberChunks']);
$otherChunks = explode(',', $scriptProperties['otherChunks']);
if ($modx->user->isMember('paid-members')) {
foreach ($subChunks as $subChunk) {
$output .= $modx->getChunk($subChunk);
}
<?php
$default = realpath(dirname(__FILE__).'/core/lexicon/en').'/';
$local = realpath(dirname(__FILE__).'/core/lexicon/nl').'/';
$showSame = false;
// find default files
$theFiles = array();
if($handle = opendir($default)) {
while(false !== ($file = readdir($handle))) {
@dannevang
dannevang / navigation.phtml
Created August 27, 2014 17:16
Remove Magento Dashboard Links
<!--
Step 1: Go To ( YourTemplate/customer/account/navigation.phtml )
Step 2: Replace This Line: <?php $_count = count($_links); ?>
-->
<?php $_count = count($_links); /* Add or Remove Account Left Navigation Links Here -*/
unset($_links['account']); /* Account Info */
unset($_links['account_edit']); /* Account Info */
unset($_links['tags']); /* My Tags */
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
<?php
/**
* =========================
* defaultTemplateByParentTv
* =========================
*
* Plugin for modX Revolution
* Set default template for children of a ressource
*
* Author:
<html>
<head>
<title>Select styles with CSS only</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
background-color: #fff;
font-family: helvetica, sans-serif;
margin: 4% 10%
}
@dannevang
dannevang / secure_install.sh
Last active August 29, 2015 14:18 — forked from Realetive/secure_install.sh
Install script for MODX
#!/bin/bash
##############
echo "
//////////////////////////////////////
// //
// Welcome to MODx autoinstaller. //
// //
//////////////////////////////////////
@dannevang
dannevang / checkxml.php
Created June 15, 2015 13:33
Get XML data from file
<?php
/* Demonstration on how to get product data from at XML file
* Mathias Dannevang <[email protected]>
*/
//Function to call the XML file
function download_page($path){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$path);
curl_setopt($ch, CURLOPT_FAILONERROR,1);
@dannevang
dannevang / performance.patch
Created November 20, 2015 16:35 — forked from DimaSoroka/performance.patch
Performance improvement for Magento Patch SUPEE-6788
Index: app/code/core/Mage/Admin/Model/Variable.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- app/code/core/Mage/Admin/Model/Variable.php (revision 2bd128c1f190cd9ea63269824f09789199565251)
+++ app/code/core/Mage/Admin/Model/Variable.php (revision )
@@ -30,6 +30,13 @@
class Mage_Admin_Model_Variable extends Mage_Core_Model_Abstract
{
@dannevang
dannevang / duplicate-delete.php
Created January 20, 2016 10:52
Script to delete duplicate gallery images from magento. HT: aadil.co
<?php
/*
* DELETE DUPLICATE GALLERY IMAGES
* 1. Edit ln 9 to match your magento install
* 2. Run from terminal: php /{your_path}/duplicate-delete.php
*
*/
include('app/Mage.php');
umask(0);