Skip to content

Instantly share code, notes, and snippets.

💭
😄

Takuro Hishikawa hissy

💭
😄
Block or report user

Report or block hissy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hissy
hissy / concrete.php
Last active Sep 17, 2019
#concrete5 Disable getting external news and help from concrete5.org
View concrete.php
<?php
/**
* Put this file at application/config/concrete.php
* Disable getting external news, help and updates from concrete5.org
*/
return [
'marketplace' => [
'enabled' => false
],
'external' => [
@hissy
hissy / view.php
Last active Jun 19, 2019
#concrete5 Check the user already submitted on express form template
View view.php
<?php
defined('C5_EXECUTE') or die('Access Denied.');
$app = \Concrete\Core\Support\Facade\Facade::getFacadeApplication();
/** @var \Concrete\Core\User\User $u */
$u = $app->make(\Concrete\Core\User\User::class);
$answered = 0;
if (isset($renderer) && is_object($renderer) && $u->isRegistered()) {
$context = $renderer->getContext();
if (is_object($context)) {
@hissy
hissy / view.php
Created Jun 17, 2019
#concrete5 An example of the custom template for page list with Vue.js
View view.php
<?php
defined('C5_EXECUTE') or die("Access Denied.");
$c = Page::getCurrentPage();
/** @var \Concrete\Core\Utility\Service\Text $th */
$th = Core::make('helper/text');
/** @var \Concrete\Core\Localization\Service\Date $dh */
$dh = Core::make('helper/date');
@hissy
hissy / view.php
Created Jun 10, 2019
#concrete5 An example of the custom template that rendered by Vue.js
View view.php
<?php
// application/blocks/topic_list/templates/your_template_name.php
use Concrete\Core\Tree\Node\Node;
use Concrete\Core\Tree\Node\Type\Category;
use Concrete\Core\Tree\Type\Topic;
defined('C5_EXECUTE') or die("Access Denied.");
$json = [];
@hissy
hissy / app.php
Created Jun 5, 2019
#concrete5 Switch theme via request path for page not found
View app.php
<?php
// Tested on 8.5.2a1
Events::addListener('on_before_render', function ($event) {
$view = $event->getArgument('view');
if ($view->getViewPath() == '/page_not_found') {
$request = \Request::getInstance();
if ($request->getPath() == '/foo' || $request->matches('/foo/*')) {
$view->setViewTheme('concrete');
@hissy
hissy / export.xml
Created Apr 15, 2019
An xml file of example Users&Groups for Migration tool #concrete5
View export.xml
<?xml version="1.0" encoding="UTF-8"?>
<concrete5-cif version="1.0">
<groups>
<group name="Administrators" description="" path="/Administrators" package=""/>
<group name="Editors" description="" path="/Editors" package=""/>
<group name="Approvers" description="" path="/Approvers" package=""/>
</groups>
<users>
<user username="editor" email="editor@example.com" language="ja_JP">
<attributes>
@hissy
hissy / MultilingualPageUrlResolver.php
Last active Jan 30, 2019
[concrete5] MultilingualPageUrlResolver: Get localized page path from original page path
View MultilingualPageUrlResolver.php
<?php
// application/src/Concrete/Url/MultilingualPageUrlResolver.php
namespace Application\Concrete\Url;
use Concrete\Core\Application\ApplicationAwareInterface;
use Concrete\Core\Application\ApplicationAwareTrait;
use Concrete\Core\Multilingual\Page\Section\Section;
use Concrete\Core\Page\Page;
use Concrete\Core\Url\Resolver\PageUrlResolver;
use Concrete\Core\Url\Resolver\UrlResolverInterface;
@hissy
hissy / app.php
Last active Jan 2, 2019
[concrete5] [Debug tool] Tooltip to display block detail
View app.php
<?php
// application/bootstrap/app.php
$dh = $app->make('helper/concrete/dashboard');
$director = $app->make('director');
$director->addListener('on_before_render', function ($event) use ($dh) {
/** @var \Concrete\Core\View\View $view */
$view = $event->getArgument('view');
$page = \Concrete\Core\Page\Page::getCurrentPage();
$p = new \Concrete\Core\Permission\Checker($page);
@hissy
hissy / README.md
Last active Dec 19, 2018
[concrete5] [v8] Bulk mapping pages between multilingual sitemaps from command line
View README.md

What this script does?

  1. Get all pages in original multilingual section
  2. Get a page in destination multilingual section that has same collection path
  3. Make a relation
  4. Go to next page

How to use

@hissy
hissy / filter_by_date.php
Last active Dec 6, 2018
#concrete5 #v8 An example of the custom template of page list: filter by date time attribute
View filter_by_date.php
<?php
defined('C5_EXECUTE') or die("Access Denied.");
/** @var \Concrete\Core\Page\PageList $list */
// Start Date is earlier than tomorrow
$tomorrow = \Carbon\Carbon::tomorrow();
$list->filterByAttribute('start_date', $tomorrow->format('Y-m-d'), '<');
// End Date is later than today
$today = \Carbon\Carbon::today();
$list->filterByAttribute('end_date', $today->format('Y-m-d'), '>=');
You can’t perform that action at this time.