Skip to content

Instantly share code, notes, and snippets.

<mt:EntryJSONTableItems>
<mt:IfEntryJSONTableItem key=“foo">
<mt:EntryJSONTableItem key=“foo”>
</mt:IfEntryJSONTableItem>
<mt:Else>
do something when items is empty
</mt:EntryJSONTableItems>
@tinybeans
tinybeans / 0_reuse_code.js
Created March 10, 2016 05:41
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@tinybeans
tinybeans / gist:6138355
Last active December 20, 2015 13:19
MTDDC 2013 サンプル - jQuery.ajax() を使って Data API からデータを取得して表示
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>MTDDC</title>
<style type="text/css">
#result-container {
position: relative;
}
#result-img {
@tinybeans
tinybeans / grep_files.pl
Created August 7, 2012 03:21
特定のディレクトリ以下のファイルを再帰的に取得して、そのファイルの中の特定のブロックを、別の行に移動する。
#!/usr/bin/perl
# Copyright (c) Tomohiro Okuwaki. http://www.tinybeans.net/blog/
use strict;
use warnings;
use utf8;
# 複数のファイルの操作
my $dir = shift;
my $files = [];
@tinybeans
tinybeans / gist:2391064
Created April 15, 2012 08:38
2階層目まではindex.htmlでそれ以降はlist_<MTCategoryBasename>.htmlにするアーカイブマッピング
<$MTSetVar name="nest_count" value="0"$><MTParentCategories><$MTSetVar name="nest_count" op="++"$></MTParentCategories><MTIf name="nest_count" gt="2">service/list_<$MTCategoryBasename$>.html<MTElse>_index.html</MTElse></MTIf>
@tinybeans
tinybeans / MTAppFieldSort
Created February 26, 2012 16:25
PowerCMS環境で、$.MTAppFieldSort()にtextを指定するとWYSWIGエディタがおかしくなるときの暫定対処法
次のように書きたいとする。
$.MTAppFieldSort({sort: 'title,excerpt,text,ext-field,keywords,tags'});
【対処方法】
text-fieldの手前を$.MTAppFieldSort()でソートして、後はtext-fieldにafter()していく。
(1) シンプルに書く
$.MTAppFieldSort({sort: 'title,excerpt'});
@tinybeans
tinybeans / MTAppInCats()はフォルダでも使える?
Created November 29, 2011 02:48
MTAppInCats()はウェブページの編集画面でも使えます。つまりフォルダごとに動作を変更することができます。
if (mtappVars.screen_id === 'edit-page') {
$.MTAppInCats({
categories: '3', // ←フォルダIDをカンマ区切りで設定
code: function(){
alert('Have a good day!'); // 処理内容を指定($.MTAppCustomize()などなど)
}
});
}
@tinybeans
tinybeans / gist:1221319
Created September 16, 2011 06:06
ランダムにバナーを表示する(mt:DynamicMTML + mt:CampaignRondom)
<mt:DynamicMTML>
<mt:CampaignRandom tag="main_visual">
<mt:CampaignAsset>
<p class="image"><img src="<$mt:AssetURL$>" alt="<$mt:AssetLabel$>" width="<$mt:AssetProperty property="image_width"$>" height="<$mt:AssetProperty property="image_height"$>" /></p>
</mt:CampaignAsset>
</mt:CampaignRandom>
</mt:DynamicMTML>
【設定ファイル】
[product_image]
fieldname = 商品画像
type = imagefield
class = post page
【テンプレート】
<?php
$imagefield = get_imagefield('product_image');
$image_id = $imagefield['id'];
@tinybeans
tinybeans / flexibleSearch-conf.js
Created February 27, 2015 21:36
flexibleSearch.js で複数の JSON ファイルを切り替えて検索するサンプル
(function ($) {
$('#search').flexibleSearch({
searchFormCreation: false,
searchDataPath: {
search_A: "/flexibleSearch/search.json",
search_B: "/flexibleSearch/search2.json",
},
searchFormAction: "/flexibleSearch/search.html",
loadingImgPath: "/flexibleSearch/loading.gif",
resultItemTmpl: [