Skip to content

Instantly share code, notes, and snippets.

@Lazerproof
Lazerproof / CachableComponent.php
Created May 12, 2020 21:41 — forked from khoatran/CachableComponent.php
OctoberCMS - CachableComponent
<?php
use Cache;
use Cms\Classes\ComponentBase;
abstract class CachableComponentBase extends ComponentBase
{
/**
* Build cache configuration which is an array: ['cachedKey' => 'The cache key value', 'cachedTimeInMinutes' => 'Cached time in minutes']
* @return mixed
@Lazerproof
Lazerproof / export_csv.php
Created February 25, 2020 18:03
Processwire CSV Import/Export
<?php
/**
* Export CSV
*
* @author Ivan Milincic <lokomotivan@gmail.com>
* @copyright 2017 Ivan Milincic
*
*/
if($input->post->export_csv) {
@mixin fill($offset: 0) {
// get a list with 4 numbers
@if type_of($offset) == 'number' {
$offset: ($offset $offset $offset $offset);
} @else if type_of($offset) == 'list' {
@if length($offset) == 2 {
$offset: join($offset, $offset);
} @else if length($offset) == 3 {
@Lazerproof
Lazerproof / ProcessDashboard.module.php
Created August 23, 2017 11:15 — forked from abdusco/ProcessDashboard.module.php
A simple dashboard module for ProcessWire 3.0+
<?php namespace ProcessWire;
class ProcessDashboard extends Process implements Module
{
public static function getModuleInfo()
{
return [
'title' => 'Orders Dashboard',
'summary' => 'Shows latest orders',
@Lazerproof
Lazerproof / font-awesome.css.sass
Created June 15, 2017 10:42 — forked from mbreit/font-awesome.css.sass
Using Font Awesome with SASS and mixins for adding icons to semantic HTML
$fontawesome_path: "." !default
@font-face
font-family: 'FontAwesome'
src: font-url('#{$fontawesome_path}/fontawesome-webfont.eot')
src: font-url('#{$fontawesome_path}/fontawesome-webfont.eot?#iefix') format("embedded-opentype"), font-url('#{$fontawesome_path}/fontawesome-webfont.woff') format("woff"), font-url('#{$fontawesome_path}/fontawesome-webfont.ttf') format("truetype")
font-weight: normal
font-style: normal
@mixin icon($icon)
@Lazerproof
Lazerproof / favicon.html
Created March 30, 2017 10:39 — forked from bcherny/favicon.html
100% cross browser favicon declaration
<!--
favicons (see http://www.jonathantneal.com/blog/understand-the-favicon)
---
icon format dimensions documentation
---- ------ ---------- -------------
apple-touch-icon PNG 152x152 https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/IconMatrix.html#//apple_ref/doc/uid/TP40006556-CH27-SW1
icon PNG 96x96
shortcut icon ICO 32x32
msapplication-TileImage PNG 144x144
@Lazerproof
Lazerproof / repeater_example.php
Created August 29, 2016 13:52 — forked from somatonic/repeater_example.php
example repeater creation and save front-end form
<?php
$mypage = $pages->get("/about/");
if($input->post->submit){
$n = 1;
$title = "element_title_$n";
$url = "external_url_$n";
$mypage->setOutputFormatting(false);
@Lazerproof
Lazerproof / form_with_fields_in_table.php
Created August 29, 2016 13:52 — forked from somatonic/form_with_fields_in_table.php
form with fields rendered in a table example
<?php
/**
* Example form using PW API
*
* A workaround to get fields display in a table
* Those fields are marked with a property added to the fields $field->tablerow
*
* Approach is to grab those fields after form is put together and maybe processed,
* loop each row and render out the fields along with possible errors and add it to a string variable $table
* while we remove the field from the form at the same time.
@Lazerproof
Lazerproof / fields
Created March 22, 2016 12:49
ProcessWire fields
hidden
------
$field = $this->modules->get('InputfieldHidden');
$field->label = __('Some Label');
$field->attr('name+id','some_label');
$field->attr('value', 'some value');
submit
------
$submit = $this->modules->get('InputfieldSubmit');
@Lazerproof
Lazerproof / ContactForm.php
Created March 22, 2016 12:24 — forked from mauricius/ContactForm.php
Simple Class for building a Bootstrap-compatible Contact Form for ProcessWire
<?php
class ContactForm
{
var $form;
var $to = 'destination@email.com';
var $toName = 'Destination Name';
public function __construct()