Skip to content

Instantly share code, notes, and snippets.

<?php
require_once(TOOLKIT . '/class.datasource.php');
Class datasourcetour_l_current_presentation_images extends SectionDatasource{
public $dsParamROOTELEMENT = 'tour-l-current-presentation-images';
public $dsParamORDER = 'asc';
public $dsParamPAGINATERESULTS = 'yes';
public $dsParamLIMIT = '1';
@ijy
ijy / EE: Store: Hide modifier option if out of stock
Last active December 18, 2015 20:48
ExpressionEngine: How to conditionally hide modifier options depending on inventory count in Expresso Store 1.6+. {option_stock_level} can be used inside the {modifier_options} tag pair to output the current stock level for that modifier option. It can also be used (as in this example) to conditionally hide modifier options if out of stock.
{modifier_options}
{if option_stock_level > 0}
<option value="{option_id}">
{option_name} {if price_mod_val} ({price_mod}) {/if}
</option>
{/if}
{/modifier_options}
@ijy
ijy / EE: Dynamic parameter values
Created June 22, 2013 22:41
How to pass in dynamic values to ExpressionEngine tag parameters. (How to use plugin tags inside EE tags). The two secret ingredients are parse="inward" to parse the dynamic inner tag first. The second is the 'random' keyword to ensure the dynamic parameter value is used instead of a placeholder string.
{exp:channel:entries parse="inward" parameter="{exp:plugin:method parameter='value' random}" }
@ijy
ijy / EE: Matrix: If no results on search
Last active December 18, 2015 20:49
Conditionally check whether a Matrix is empty when searching on a particular column. Can be used with a Playa relationship field.
@ijy
ijy / Symphony 2.3 Custom Data Source.php
Last active December 18, 2015 20:49
Symphony 2.3 custom Data Source shell.
<?php
require_once(TOOLKIT . '/class.datasource.php');
Class datasourcetour_l_current_presentation_images extends SectionDatasource{
public $dsParamROOTELEMENT = 'tour-l-current-presentation-images';
public $dsParamORDER = 'asc';
public $dsParamPAGINATERESULTS = 'yes';
public $dsParamLIMIT = '1';
@ijy
ijy / EE: Matrix: Row count not empty
Created June 22, 2013 22:46
Return the total number of rows in a Matrix where a specified column is not empty. the_matrix refers to the name of the Matrix field. my_col refers to the column to search on.
{the_matrix:total_rows search:my_col="not IS_EMPTY"}
@ijy
ijy / querystring-params.php
Created June 28, 2013 14:04
Convert query string params into an arrary
$querystring = 'a=foo&b=bar';
parse_str($querystring, $params);
// Test it
echo "<pre>";
print_r($params);
echo "</pre>";
@ijy
ijy / chromeframe.html
Created June 28, 2013 14:05
Add Chrome Frame prompt for IE6+7.
<!-- Prompt IE6 users to install Chrome Frame -->
<!--[if lt IE 8 ]>
<script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
<script>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script>
<![endif]-->
@ijy
ijy / simple-server.txt
Last active December 19, 2015 02:39 — forked from JeffreyWay/gist:1525217
Instant Server for Current Directory.
alias server='open http://localhost:8000 && python -m SimpleHTTPServer'
@ijy
ijy / jquery-pubsub.js
Created June 28, 2013 14:19
jQuery PubSub in three lines. This will work in IE9+, so it's a perfect choice for jQuery 2.0 projects.
var o = $({});
$.subscribe = o.on.bind(o);
$.publish = o.trigger.bind(o);