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
Last active June 19, 2019 20:43
#concrete5 Check the user already submitted on express form template
<?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 June 17, 2019 23:30
#concrete5 An example of the custom template for page list with Vue.js
<?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 June 10, 2019 06:18
#concrete5 An example of the custom template that rendered by Vue.js
<?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 June 5, 2019 02:13
#concrete5 Switch theme via request path for page not found
<?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 April 15, 2019 15:56
An xml file of example Users&Groups for Migration tool #concrete5
<?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="[email protected]" language="ja_JP">
<attributes>
@hissy
hissy / MultilingualPageUrlResolver.php
Last active January 30, 2019 13:28
[concrete5] MultilingualPageUrlResolver: Get localized page path from original page path
<?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 January 2, 2019 07:57
[concrete5] [Debug tool] Tooltip to display block detail
<?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 December 19, 2018 10:48
[concrete5] [v8] Bulk mapping pages between multilingual sitemaps from command line

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 December 6, 2018 08:21
#concrete5 #v8 An example of the custom template of page list: filter by date time attribute
<?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'), '>=');
@hissy
hissy / readme.md
Last active May 5, 2023 19:43
[concrete5] How to fix "failed to open stream" error when you delete doctrine proxies directory

How to fix "failed to open stream" error when you delete doctrine proxies directory

Whoops\Exception\ErrorException thrown with message "require(/path/to/concrete5/application/config/doctrine/proxies/__CG__ConcreteCoreEntityExpressEntity.php): failed to open stream: No such file or directory"

Enable "Doctrine Dev mode" manually

Add application/config/concrete.php file (or modify it) like below: