Skip to content

Instantly share code, notes, and snippets.

View jules0x's full-sized avatar
🔥

Jules jules0x

🔥
View GitHub Profile
@jules0x
jules0x / remove_cms_menu_items.php
Last active August 20, 2021 00:30
Remove CMS menu items
CMSMenu::remove_menu_class(MenuAdmin::class);
@jules0x
jules0x / cms_css.md
Last active July 7, 2018 08:19
Custom CSS for CMS

Add custom CSS to the CMS

LeftAndMain:
  extra_requirements_css:
    - app/code/css/custom.css
@jules0x
jules0x / Custom-CMS-Menu-Item-Extension.php
Last active August 29, 2015 14:26
An example of a custom CMS menu-item created using a DataExtension
<?php
class CustomMenuItemExtension extends LeftAndMainExtension {
public function init() {
// unique identifier for this item. Will have an ID of Menu-$ID
$id = 'LinkToGoogle';
// your 'nice' title
$title = 'Google';
@jules0x
jules0x / _config.php
Created August 31, 2015 22:41
Exclude reports from CMS using 'add_excluded_reports'
<?php
SS_Report::add_excluded_reports(
array(
'SideReport_BrokenRedirectorPages',
'SideReport_BrokenVirtualPages',
'SideReport_BrokenFiles',
'CwpStatsReport',
'SideReport_BrokenLinks',
'BrokenLinksReport',
@jules0x
jules0x / _config.php
Last active March 1, 2020 22:54
# Sitemode CSS Add some custom styling to visually the environment you're currently editing. Helps prevent accidently testing things in prodution.
<?php
//Set CMS style based on environment type
if (Director::isDev()) {$sitemodeCSS = 'app/css/sitemode-dev.css';}
if (Director::isTest()) {$sitemodeCSS = 'app/css/sitemode-test.css';}
if (Director::isLive()) {$sitemodeCSS = 'app/css/sitemode-live.css';}
Config::inst()->update('LeftAndMain', 'extra_requirements_css', [
$sitemodeCSS
]);
@jules0x
jules0x / _config.php
Last active March 1, 2020 22:58
# TinyMCE custom classes ### Apply custom classes to html elements via a dropdown
<?
$htmlEditorConfig = HtmlEditorConfig::get('cms');
// Add half' and 'third' wrappers to tinyMCE (will appear in styles drop-down).
$htmlEditorConfig->setOption('style_formats', [
[
'title' => 'Half (md)',
'block' => 'div',
'wrapper' => true,
@jules0x
jules0x / tinymce_toggle.md
Last active October 24, 2022 16:56
# Add buttons to the tinyMCE toolebar to toggle custom items (styles, classes etc.)

#TinyMCE style toggle button

First of all, you need to define a custom format:

formats: {
   custom_format: {inline: 'span', attributes: {class: 'some_css_class'}}
}

Then you'll have to add a button to your toolbar:

@jules0x
jules0x / tinymce_hotkeys.md
Last active March 1, 2020 23:00
# TinyMCE hotkeys to trigger editor actions

#TinyMCE hotkeys

Add 'format' to initalization:

formats: {text_center: {selector: 'p,h1,h2,h3,h4,h5,table', classes: 'text-center'}}

Then add the shortcut in 'setup':

setup: function (ed) {
#!/bin/sh
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \.php`
# Determine if a file list is passed
if [ "$#" -eq 1 ]
then
oIFS=$IFS
IFS='
@jules0x
jules0x / query.sql
Last active June 21, 2023 21:36
SQL: Query row count for all tables in DB
SELECT table_name, table_rows
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'db_name'
ORDER BY table_rows desc;