Skip to content

Instantly share code, notes, and snippets.

View ChristopherDosin's full-sized avatar
:octocat:
Out sick

Christopher Dosin ChristopherDosin

:octocat:
Out sick
View GitHub Profile
{# Get the requested entry slug from the URL #}
{% set requestedSlug = craft.app.request.segments|last %}
{# Fetch the entry with that slug #}
{% set entry = craft.entries()
.slug(requestedSlug|literal)
.anyStatus()
.one() %}
{% if entry|length %}
@ChristopherDosin
ChristopherDosin / smarty_modifier_mediaurl.php
Created December 29, 2019 17:47
Shopware Media Modifier Smarty
<?php
function smarty_modifier_mediaurl($value, $format = array())
{
if (is_numeric($value)) {
$id = (int)$value;
$media = Shopware()->Models()->getRepository('Shopware\Models\Media\Media')->findOneBy(['id' => $id]);
if ($media) {
$path = $media->getPath();
@ChristopherDosin
ChristopherDosin / error.log
Created December 28, 2019 10:47
shopware npm error
shopware [6.1] sudo bin/build-js.sh
Password:
readlink: illegal option -- f
usage: readlink [-n] [file ...]
usage: dirname path
usage: dirname path
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /vendor/shopware/administration/Resources/package.json
npm ERR! errno -2
<form class="profile-form" method="post" accept-charset="UTF-8" enctype="multipart/form-data">
{{ actionInput('users/save-user') }}
{{ csrfInput() }}
{{ hiddenInput('userId', currentUser.id) }}
<input type="hidden" name="fields[qualification]" value="">
{% for item in currentUser.qualification %}
<input type="hidden" name="fields[qualification][]" value="{{ item.id }}">
{% endfor %}
<input type="hidden" name="fields[qualification][new1][enabled]" value="1">
@ChristopherDosin
ChristopherDosin / store-hours.twig
Last active December 13, 2019 06:06
Store hours
<form method="post" accept-charset="UTF-8" enctype="multipart/form-data">
{{ actionInput('users/save-user') }}
{{ csrfInput() }}
{{ hiddenInput('userId', currentUser.id) }}
<div class="grid-x grid-margin-x">
<div
class="cell small-12 large-6 weekdays">
{# Show all days with Monday first #}
{% set range = currentUser.openingHours.getRange(1, 0) %}
{% for day in range %}
@ChristopherDosin
ChristopherDosin / jquery.sticky-element.js
Created January 3, 2019 11:51
Shopware jQuery sticky element
/**
* Sticky plugin to add a class based on the
* scroll position.
*/
$.plugin('swStickyElement', {
defaults: {
/**
* The css class for the sticky element.
*
* @property stickyCls
// Creates a new promise that automatically resolves after some timeout:
Promise.delay = function (time) {
return new Promise((resolve, reject) => {
setTimeout(resolve, time)
})
}
// Throttle this promise to resolve no faster than the specified time:
Promise.prototype.takeAtLeast = function (time) {
return new Promise((resolve, reject) => {
@ChristopherDosin
ChristopherDosin / installc9.sh
Created July 17, 2018 01:15
Simple script to install Cloud9 on an Ubuntu Server
#!/bin/bash
# Simple script to install Cloud9 on an Ubuntu Server
apt-get update && apt-get install build-essential -y
apt-get install git -y
apt-get install nodejs -y
apt-get install npm -y
apt-get install python2.7 python-pip -y
# cd ~/to/your/directory
@ChristopherDosin
ChristopherDosin / ajaxform.js
Created February 18, 2018 16:45
Send form with ajax
$('#id-form button[type=submit]').click(function(e){
e.preventDefault();
$(this).text('Einen moment...');
var form = jQuery(this).parents("form:first");
var dataString = form.serialize();
var formAction = form.attr('action');
$.ajax({
@ChristopherDosin
ChristopherDosin / gist:0da262095d45806dac383560007ccfbe
Created January 30, 2018 17:46
Cloud9 smarty syntax highlighting
{
"ace": {
....
"custom-types": {
"json()": {
"tpl": "smarty"
}
}