Skip to content

Instantly share code, notes, and snippets.

View zanderwar's full-sized avatar
👺

zanderwar zanderwar

👺
View GitHub Profile
@zanderwar
zanderwar / README.md
Created January 7, 2024 10:55
Shopify Query Params As Variables

Sometimes it may be useful to use query parameter values in your liquid template within Shopify, however Shopify does not expose this information.

Conveniently the content_for_header output actually includes the full page url that is being used, so with a chain of liquid filters we can actually extract this information into something we can use.

Copy the file below into your snippets folder, and on any template that you need to access query strings, simply use the following code:

{% include 'query-to-variables' %}
Sorting by {{ paramSortBy }}
@zanderwar
zanderwar / DataObjectLinkTracking.php
Last active January 31, 2018 04:30
Just in case someone else wants to use HTMLText in DataObjects and be able to publish the images that clients can upload into TinyMCE - SilverStripe 4
<?php
namespace Vulcan\Common\Traits;
use SilverStripe\Assets\File;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\HasManyList;
/**
* Trait DataObjectLinkTracking
@zanderwar
zanderwar / Page.php
Created January 20, 2018 03:18
Easier requirements for SilverStripe 4
<?php
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\CMS\Model\SiteTree;
/**
* Class Page
*/
class Page extends SiteTree
{
@zanderwar
zanderwar / AbstractApiController.php
Created October 15, 2017 06:41
Just a simple API output controller for SilverStripe 4
<?php
namespace Zanderwar\Api\Controllers;
use SilverStripe\Control\Controller;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Convert;
/**
@zanderwar
zanderwar / ModifyModelAdminGridFieldConfig.php
Created June 9, 2017 12:49
An example of swapping the GridFieldConfig of a particular GridField in a ModelAdmin
<?php
class Example extends ModelAdmin
{
private static $url_segment = 'Example';
private static $menu_title = 'Example';
private static $managed_models = [
Site::class
@zanderwar
zanderwar / PopulateFormDefaults.php
Last active June 14, 2017 04:43
Populates a SilverStripe Form subclass with DataObject values
<?php
class MyForm extends Form
{
/**
* @param Customer $customer
* @return $this
*/
public function setObject(DataObject $object)
{
<img src='http://placehold.it/300x300' class='ipsThumb'/>
<img src='http://placehold.it/300x300' class='ipsThumb ipsThumb_large'/>
<img src='http://placehold.it/300x300' class='ipsThumb ipsThumb_medium'/>
<img src='http://placehold.it/300x300' class='ipsThumb ipsThumb_small'/>
<img src='http://placehold.it/300x300' class='ipsThumb ipsThumb_tiny'/>
<div class='ipsMessage ipsMessage_info'><strong>Information:</strong> Look behind you!</div>
<div class='ipsMessage ipsMessage_error'><strong>Danger:</strong> Seriously..... Look behind you!</div>
<div class='ipsMessage ipsMessage_warning'><strong>Warning:</strong> Is that a robot?!? Be careful it bites!</div>
<div class='ipsMessage ipsMessage_success'><strong>Success:</strong> Wow where did you get that rocket launcher! *BOOM*</div>
<div class='ipsMessage ipsMessage_general'><strong>General:</strong> Yay it has powered down. Thank god no one got hurt!</div>
<!-- TAGS -->
<span class='ipsTag_prefix'>I am a tag</span>
<div class='ipsTag_prefix'><span>I am another tag</span></div>
<div class='ipsTag_prefix'><span>I am the tag everybody speaks of!</span></div>
<!-- BADGES -->
<span class='ipsBadge ipsBadge_warning ipsBadge_large'>WARNING BADGE</span>
<span class='ipsBadge ipsBadge_positive ipsBadge_large'>POSITIVE BADGE</span>
<span class='ipsBadge ipsBadge_negative ipsBadge_large'>NEGATIVE BADGE</span>
<span class='ipsBadge ipsBadge_neutral ipsBadge_large'>NEUTRAL BADGE</span>
<div class='ipsGrid'>
<div class='ipsGrid_span4'>span4</div>
<div class='ipsGrid_span3'>span3</div>
<div class='ipsGrid_span5'>span5</div>
</div>