Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
😄

Takuro Hishikawa hissy

💭
😄
View GitHub Profile
@hissy
hissy / EventService.php
Created Apr 6, 2021
[concrete5] [V8] Create a draft detail page if you make a draft calendar event, and approve the page when you publish that event.
View EventService.php
<?php
// application/src/Calendar/Event/EventService.php
namespace Application\Calendar\Event;
use Concrete\Core\Entity\Calendar\Calendar;
use Concrete\Core\Entity\Calendar\CalendarEvent;
use Concrete\Core\Entity\Calendar\CalendarEventVersion;
use Concrete\Core\Page\Page;
use Concrete\Core\Page\Type\Type;
@hissy
hissy / README.md
Last active Mar 23, 2021
[concrete5][V8] Check all database migrations already run or missed
View README.md

This script is related with migration error on upgrade from 8.5.2 or before.

https://github.com/concrete5/concrete5/issues/8771

You can check if there're missing migrations on your concrete5 site before upgrade it.

How to run the script

  1. Download checkMigrations.php and upload it
  2. Run it with c5:exec command
@hissy
hissy / HttpServiceProvider.php
Last active Dec 16, 2020
[concrete5] [V8] Fix: IE tries to download json file when you hit save button of content block
View HttpServiceProvider.php
<?php
namespace Application\Http;
use Concrete\Core\Http\ResponseFactoryInterface;
class HttpServiceProvider extends \Concrete\Core\Http\HttpServiceProvider
{
public function register()
{
parent::register();
@hissy
hissy / README.md
Last active Sep 24, 2020
[concrete5][V8] An automated job to restore "Page Not Found" page
View README.md

It should exist only one "Page Not Found" page with "/page_not_found" path on concrete5 system. However, you're able to delete that page or change the URL accidentally. You can install it from dashboard, but it won't work correctly if you enables multilingual sections. If it happened, sometimes concrete5 can't render 404 correctly and may occur an infinite loop. I got a Segmentation fault error due to this case.

This job was written for re-installing "/page_not_found" page correctly. Please upload this restore_page_not_found.php file into your /application/jobs directory, then install it from Dashboard > System & Settings > Optimization > Automated Jobs page. After install it, just push the "Run" button.

@hissy
hissy / demo_users.xml
Created Aug 9, 2020
[concrete5] Example users & groups
View demo_users.xml
<?xml version="1.0" encoding="UTF-8"?>
<concrete5-cif version="1.0">
<users>
<user username="editor" email="editor@example.com">
<groups>
<group path="/Editor"/>
</groups>
</user>
<user username="approver_a" email="approver_a@example.com">
<groups>
@hissy
hissy / app.php
Last active Jul 1, 2020
[concrete5] Add express entry details into sitemap.xml
View app.php
<?php
/* @var Concrete\Core\Application\Application $app */
/* @var Concrete\Core\Console\Application $console only set in CLI environment */
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $director */
$director = $app->make(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class);
$director->addListener('on_sitemap_xml_ready', static function ($event) use ($app) {
/** @var \Concrete\Core\Page\Sitemap\Event\XmlReadyEvent $event */
$xml = $event->getDocument();
@hissy
hissy / app.php
Created Jul 1, 2020
[concrete5] Add express entry details into sitemap.xml
View app.php
<?php
/* @var Concrete\Core\Application\Application $app */
/* @var Concrete\Core\Console\Application $console only set in CLI environment */
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $director */
$director = $app->make(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class);
$director->addListener('on_sitemap_xml_ready', static function ($event) use ($app) {
/** @var \Concrete\Core\Page\Sitemap\Event\XmlReadyEvent $event */
$xml = $event->getDocument();
@hissy
hissy / controller.php
Created Jul 1, 2020
[concrete5] Example: Customize SEO meta tags for express entry detail
View controller.php
<?php
namespace Application\Block\ExpressEntryDetail;
use Concrete\Core\Html\Service\Seo;
use Concrete\Core\Url\SeoCanonical;
class Controller extends \Concrete\Block\ExpressEntryDetail\Controller
{
public function action_view_express_entity($exEntryID = null)
{
@hissy
hissy / generate_list.php
Last active Jun 30, 2020
[concrete5] List of block types
View generate_list.php
| Block Type Handle | Block Type Name |
| ---- | ---- |
<?php
$types = \Concrete\Core\Block\BlockType\BlockTypeList::getInstalledList();
/** @var \Concrete\Core\Entity\Block\BlockType\BlockType $type */
foreach ($types as $type) {
echo sprintf('|%s|%s|', $type->getBlockTypeHandle(), $type->getBlockTypeName());
echo PHP_EOL;
}
@hissy
hissy / clear_empty_workflow_progress.php
Last active Jun 12, 2020
[concrete5 legacy] A job to deletes empty "Compare Versions" alerts.
View clear_empty_workflow_progress.php
<?php
defined('C5_EXECUTE') or die("Access Denied.");
class ClearEmptyWorkflowProgress extends Job
{
public function getJobName()
{
return t("Clear Empty Workflow Progress");