Skip to content

Instantly share code, notes, and snippets.

@veganista
veganista / example.php
Created September 26, 2013 10:28
Getting the URL of category in OpenCart.
<?php echo $this->url->link('product/category', 'path=96'); ?>
// http://example.com/category-three/
<?php echo $this->url->link('product/category', 'path=63_78'); ?>
// http://example.com/category-one/category-two/
<?php echo $this->url->link('product/category', 'path=63_78_96'); ?>
@veganista
veganista / arrayToTable.js
Last active October 22, 2021 00:06
jQuery array to HTML table.
var arrayToTable = function (data, options) {
"use strict";
var table = $('<table />'),
thead,
tfoot,
rows = [],
row,
i,
@veganista
veganista / gist:5764323
Created June 12, 2013 10:42
Batch resize images from CLI with image magick
convert *.jpg -resize 236 -set filename:filename '%t-%wx%h' 'resized/%[filename:filename].jpg'
public function beforeSave(Model $model, array $options = array()){
var_dump($model->data['User']);
//array (size=4)
// 'id' => string '66' (length=2)
// 'first_name' => string 'new first name' (length=14)
// 'last_name' => string 'new last name' (length=13)
// 'email' => string 'liam@email.com' (length=14)
$x = $model->find('first', array('conditions' => array($model->alias . '.' .$model->primaryKey => $model->id), 'contain' => 'User'));
/*
* If this doenst work then try the below
*/
echo $this->Form->input('Applicant.date_of_birth', array(
'type' => 'date',
'dateFormat' => 'DMY',
'minYear' => date('Y') - 110,
'maxYear' => date('Y')- 18,
)
);
$dob = explode('-', $applicationData['Applicant']['date_of_birth']);
$dobDayArray = explode(' ', $dob[2]);
$dobDay = $dobDayArray[0];
$dobMonth = $dob[1];
$dobYear = $dob[0];
echo $this->Form->input('Applicant.date_of_birth', array(
'type' => 'date',
'dateFormat' => 'DMY',
//current find results look like this
array
0 =>
array
0 =>
array
'year' => string '2012' (length=4)
'month' => string 'May' (length=3)
'count' => string '5' (length=1)
1 =>
//set error handling up
libxml_use_internal_errors(true);
//path to the validation file
$validationSchema = dirname(__FILE__).DS.'docs'.DS.'tff'.DS.'XMLImport.xsd';
//set up a new document to work with
$doc = new DOMDocument();
$doc->formatOutput = true;
$doc->preserveWhiteSpace = false;
class User extends AppModel {
public $name = 'User';
public $belongsTo = array(
'FriendOne' => array(
'className' => 'Friend',
'foreignKey' => 'friend_1_id',
),
'FriendTwo' => array(
'className' => 'Friend',
'foreignKey' => 'friend_2_id',
@veganista
veganista / destroy-sample-data.php
Created May 10, 2012 14:17 — forked from mgirouard/destroy-sample-data.php
A quick hack to destroy all sample data in an OpenCart catalog.
<?php
$options = getopt('p:');
$prefix = empty($options['p'])
? realpath('.')
: realpath($options['p']);
if (empty($prefix)) {
die("Bad prefix. Try again.\n");
}