Skip to content

Instantly share code, notes, and snippets.

View hissy's full-sized avatar
💭
😄

Takuro Hishikawa hissy

💭
😄
View GitHub Profile
@hissy
hissy / view.php
Created February 25, 2014 15:29
[concrete5] Display Year as heading in the list of Page List template
<?php
$dh = Loader::helper('date');
$year = new DateTime('first day of next year');
$isFirst = true;
?>
<?php foreach ($pages as $page):
// Prepare data for each page being listed...
$title = $th->entities($page->getCollectionName());
@hissy
hissy / view.php
Created March 18, 2014 23:49
#concrete5 #PageList Force sort option from Page List Block template
<?php
defined('C5_EXECUTE') or die("Access Denied.");
$rssUrl = $showRss ? $controller->getRssUrl($b) : '';
$th = Loader::helper('text');
// Get PageList again
$pl = $controller->getPageList();
// Set sortby
$pl->sortBy('ak_example_attribute_handle','asc');
// Get pages again
@hissy
hissy / view.php
Last active August 29, 2015 13:57
#concrete5 #DesignerContentPro Manual Nav block made with Designer Content Pro ("Combo" Link field, additional option field)
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); ?>
<?php /* This block was made with Designer Content Pro. Visit http://theblockery.com/dcp for documentation. */ ?>
<?php
/**
* link: Link Field
* css_class: Textbox field
*/
// Get current page path
@hissy
hissy / default.php
Created March 30, 2014 17:48
#concrete5 The link to force desktop theme
<?php
$uh = Loader::helper('concrete/urls');
$url = $uh->getToolsURL('disable_mobile') . '?rcID=' . $c->getCollectionID();
?>
<a href="<?php echo $url; ?>"><?php echo t('View desktop site'); ?></a>
@hissy
hissy / controller.php
Last active August 29, 2015 14:02
[concrete5] Add split form for date/time attribute type (5.6)
<?php
defined('C5_EXECUTE') or die("Access Denied.");
class DateTimeAttributeTypeController extends Concrete5_Controller_AttributeType_DateTime {
public function form() {
$this->load();
$dt = Loader::helper('form/date_time');
$caValue = $this->getValue();
$html = Loader::helper('html');
<h1><?php
$c = Page::getCurrentPage();
$nh = Loader::helper('navigation');
// concrete5 第4階層以降であれば、第3階層 のページタイトルを表示させる。
// [現在のページタイトル] - [第3階層のページタイトル]
// ページ属性 display_secondary_title がチェックされていれば第3階層のタイトルを表示しない
// $trail [0] はトップ
// $trail [1] は第2階層
echo h($c->getCollectionName());
if (!$c->getAttribute('display_secondary_title')){
@hissy
hissy / site_post.php
Created July 9, 2014 03:02
#concrete5 quick debug snippet
<?php
$req = Request::get();
if ($req->getRequestPath() == 'debug') {
// debug some stuff
exit;
}
@hissy
hissy / view.php
Last active August 29, 2015 14:04
#concrete5 Override View to exclude tablet devices from checkMobileView
<?php
// For concrete5 ~5.6.x
// libraries/view.php
defined('C5_EXECUTE') or die("Access Denied.");
class View extends Concrete5_Library_View {
public function checkMobileView() {
if(isset($_COOKIE['ccmDisableMobileView']) && $_COOKIE['ccmDisableMobileView'] == true) {
define('MOBILE_THEME_IS_ACTIVE', false);
@hissy
hissy / controller.php
Created July 16, 2014 08:53
#concrete5 How to load required models by the package controller
<?php
defined('C5_EXECUTE') or die("Access Denied.");
class ExamplePackage extends Package {
protected $pkgHandle = 'example';
protected $appVersionRequired = '5.6.3';
protected $pkgVersion = '1.0';
@hissy
hissy / controller.php
Last active August 29, 2015 14:04
an example of 5.7 compatible package controller (just trial)
<?php
namespace Concrete\Package\SocialShareLite;
use Package;
use BlockType;
class Controller extends Package {
protected $pkgHandle = 'social_share_lite';
protected $appVersionRequired = '5.6.9';
protected $pkgVersion = '1.1';