Skip to content

Instantly share code, notes, and snippets.

View hissy's full-sized avatar
💭
😄

Takuro Hishikawa hissy

💭
😄
View GitHub Profile
@hissy
hissy / README.md
Last active September 24, 2020 09:13
[concrete5][V8] An automated job to restore "Page Not Found" page

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 August 9, 2020 09:51
[concrete5] Example users & groups
<?xml version="1.0" encoding="UTF-8"?>
<concrete5-cif version="1.0">
<users>
<user username="editor" email="[email protected]">
<groups>
<group path="/Editor"/>
</groups>
</user>
<user username="approver_a" email="[email protected]">
<groups>
@hissy
hissy / app.php
Last active July 1, 2020 10:46
[concrete5] Add express entry details into sitemap.xml
<?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 July 1, 2020 10:22
[concrete5] Add express entry details into sitemap.xml
<?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 July 1, 2020 09:58
[concrete5] Example: Customize SEO meta tags for express entry detail
<?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 June 30, 2020 20:15
[concrete5] List of block types
| 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 June 12, 2020 05:18
[concrete5 legacy] A job to deletes empty "Compare Versions" alerts.
<?php
defined('C5_EXECUTE') or die("Access Denied.");
class ClearEmptyWorkflowProgress extends Job
{
public function getJobName()
{
return t("Clear Empty Workflow Progress");
@hissy
hissy / database.php
Last active December 16, 2021 02:19
#concrete5 set sql_mode from database.php config file
<?php
/**
* How to set sql_mode from database.php
* It will help to solve the error like "SQLSTATE[42000]: Syntax error or access violation:
* 1055 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column
* 'concrete5.cv.cvPublishDate' which is not functionally dependent on columns in GROUP BY clause;
* this is incompatible with sql_mode=only_full_group_by"
*/
@hissy
hissy / empty_trash.php
Created October 16, 2019 20:44
empty trash
<?php
use Concrete\Core\Page\Page;
use Concrete\Core\Page\PageList;
use Concrete\Core\Support\Facade\Facade;
$app = Facade::getFacadeApplication();
$app->make('cache/request')->disable();
$app->make('cache/expensive')->disable();
$app->make('cache')->disable();
@hissy
hissy / bulk_clear_page_paths.php
Last active October 23, 2019 13:01
#concrete5 c5:exec command to bulk clear page paths for all pages
<?php
$list = new \Concrete\Core\Page\PageList();
$list->ignorePermissions();
$pages = $list->getResults();
$count = 0;
/** @var \Concrete\Core\Page\Page $page */
foreach ($pages as $page) {