Skip to content

Instantly share code, notes, and snippets.

View katzueno's full-sized avatar

Katz Ueno katzueno

View GitHub Profile
@katzueno
katzueno / login.php
Created April 20, 2015 23:51
If you want to redirect to previously logged in page for concrete5.6.x / concretete5.6.x でログイン後に前居たページにリダイレクトさせたい場合。
<?php
// 参考: http://ja.katzueno.com/2014/05/3104/
// テーマ埋め込みの場合
<a href="<?php echo $this->url('/login', 'forward') . $c->getCollectionID() . '/';?>">ログイン</a>
<?php
// テーマ以外で埋め込みの場合
$c = Page::getCurrentPage(); // テーマだったら代入されているはずなのでここの行は必要ないです
?>
@katzueno
katzueno / breadcrumb.php
Created May 26, 2015 03:08
Original Breadcramp.php
<?php defined('C5_EXECUTE') or die("Access Denied.");
$navItems = $controller->getNavItems(true); // Ignore exclude from nav
$c = Page::getCurrentPage();
if (count($navItems) > 0) {
echo '<nav role="navigation" aria-label="breadcrumb">'; //opens the top-level menu
echo '<ol class="breadcrumb">';
@katzueno
katzueno / global_nav.php
Created May 30, 2015 04:21
Sakan テーマのグローバルナビで、英語判定を行うチェックを追加。英語だったら、ハンドルを表示しない。
<?php defined('C5_EXECUTE') or die("Access Denied.");
$nh = Core::make('helper/navigation');
$th = Core::make('helper/text');
$trail = $nh->getTrailToCollection($c);
$isRoot = null;
if (is_array($trail) && count($trail) > 1) {
$count = count($trail);
array_splice($trail, $count - 1);
$topC = array_pop($trail);
@katzueno
katzueno / MultilingualGlobalArea.php
Created June 10, 2015 00:11
concrete5.7.x エリアを多言語対応する方法
<?php
$ms = \Concrete\Core\Multilingual\Page\Section\Section::getCurrentSection();
if (is_object($ms)) {
if ($ms->getLocale() == 'en_US') {
$a = new GlobalArea('Global Nav English');
}
}
if (!is_object($a)) {
$a = new GlobalArea('Global Nav');
}
@katzueno
katzueno / TopicCount.php
Created July 19, 2015 11:23
Display the number of the pages with a particular topic value in concrete5.7
// 5.6 の場合
Loader::model('page_list');
$pl = new PageList();
$pl->filterByAttribute('attr_name','attr_value','like');
echo $pl->getTotal();
// 5.7 でトピック属性
// /application/blocks/topic_list/view.php
// クラスを読み込み
@katzueno
katzueno / files.php
Last active September 10, 2015 01:53
Quick fix of FileManager upto 5.7.5.1 (concrete/controllers/search/files.php)
<?php
namespace Concrete\Controller\Search;
use Concrete\Core\Http\ResponseAssetGroup;
use Controller;
use FileList;
use \Concrete\Core\Search\StickyRequest;
use \Concrete\Core\File\Search\ColumnSet\ColumnSet as FileSearchColumnSet;
use \Concrete\Core\File\Search\Result\Result as FileSearchResult;
use FileAttributeKey;
@katzueno
katzueno / page_list_view.php
Last active February 25, 2016 03:32
Page List Customization to include the Main area of the content
<?php
defined('C5_EXECUTE') or die("Access Denied.");
$th = Loader::helper('text');
$c = Page::getCurrentPage();
$dh = Core::make('helper/date'); /* @var $dh \Concrete\Core\Localization\Service\Date */
?>
<? if ( $c->isEditMode() && $controller->isBlockEmpty()) { ?>
<div class="ccm-edit-mode-disabled-item"><?=t('Empty Page List Block.')?></div>
<? } else { ?>
@katzueno
katzueno / page_list_view_1st_block.php
Last active September 10, 2015 10:23
Get the 1st block only
<?php
defined('C5_EXECUTE') or die("Access Denied.");
$th = Loader::helper('text');
$c = Page::getCurrentPage();
$dh = Core::make('helper/date'); /* @var $dh \Concrete\Core\Localization\Service\Date */
?>
<? if ( $c->isEditMode() && $controller->isBlockEmpty()) { ?>
<div class="ccm-edit-mode-disabled-item"><?=t('Empty Page List Block.')?></div>
<? } else { ?>
@katzueno
katzueno / default.php
Created October 28, 2015 12:55
concrete5 特定ページで使用しているブロックのID取得
<?php
$page = Page::getByID(1); // cID で指定したページのオブジェクトを指定
$blocks = $page->getBlocks("Main"); // 指定した「Main」エリアのブロックの情報を取得
if ($blocks) {
foreach($blocks as $block) {
echo h($block->bID) . ", ";
}
}