Skip to content

Instantly share code, notes, and snippets.

View YuzuruSano's full-sized avatar

Yuzuru Sano (sizenkainookite) YuzuruSano

  • Kyoto,Japan
View GitHub Profile
@katzueno
katzueno / add_page_by_composer.php
Created November 24, 2016 14:55 — forked from YuzuruSano/add_page_by_composer.php
コンポーザーを通して新規ページを追加して、初期出力の記事ブロックに記事を挿入する。自動実行ジョブにどうぞ
<?php
//ページタイプの「出力」で'Main'エリアにコンポーザーで扱うcontentブロックを入れてる場合
$pageType = \PageType::getByHandle('ページタイプハンドル');
$template = $pageType->getPageTypeDefaultPageTemplateObject();
$d = $pageType->createDraft($template);
$d->setPageDraftTargetParentPageID(親ページID);
$pageType->savePageTypeComposerForm($d);
$pageType->publish($d);
//$dには追加したページオブジェクトが入ってくる
@hassansin
hassansin / eloquent-cheatsheet.php
Last active May 23, 2024 07:51
Laravel 5 Eloquent CheatSheet #laravel #eloquent
Model::
/*Select*/
select('col1','col2')
->select(array('col1','col2'))
->select(DB::raw('businesses.*, COUNT(reviews.id) as no_of_ratings, IFNULL(sum(reviews.score),0) as rating'))
->addSelect('col3','col4')
->distinct() // distinct select
/*From*/
@hissy
hissy / controller.php
Created September 25, 2014 13:52
#concrete5 #5.7 Example of override config values from package
<?php
namespace Concrete\Package\JapaneseCommunity;
use Config;
defined('C5_EXECUTE') or die('Access Denied.');
class Controller extends \Concrete\Core\Package\Package {
protected $pkgHandle = 'japanese_community';
@mmccall10
mmccall10 / c5advancedTextArea.php
Last active February 16, 2016 03:17
Advanced Text Area Concrete5
<?php
$form = Loader::helper('form');
Loader::element('editor_config');
Loader::element('editor_controls');
echo $form->textarea("textareaID", $details, array('class'=>"ccm-advanced-editor"));
?>
@fairlane57
fairlane57 / concrete5-useful.php
Last active February 16, 2016 03:18
Useful Concrete5 Snippets
# -------------------
# homepage URL
# -------------------
<?php echo DIR_REL; ?>
# -------------------
# Theme path
# -------------------
<?php echo $this->getThemePath(); ?>
@koizuss
koizuss / Default.sublime-keymap
Last active November 8, 2018 01:34
Mac上でDocblockr Pluginとgoogle日本語入力を使っていてコメント内でENTERを押したら入力内容が消える問題を回避(とりあえず)
[
// open a docblock with enter
{ "keys": ["enter"], "command": "jsdocs",
"context": [
{ "key": "setting.auto_indent", "operator": "equal", "operand": true, "match_all": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*(\\/\\*|###)\\*$", "match_all": true }
]
},
@wokamoto
wokamoto / wp-custom-search.php
Last active May 5, 2024 08:06
WordPress でユーザー名とか、タグ名・カテゴリ名も検索対象に
<?php
function custom_search($search, $wp_query) {
global $wpdb;
//サーチページ以外だったら終了
if (!$wp_query->is_search)
return $search;
if (!isset($wp_query->query_vars))
return $search;