I am mikek's Blog

The personal blog of Mike Karthauser, who you may know from Brightstorm Limited or the internet.

Disabling user interface code updates

If your site is relying on an external deployment system (perhaps with a staging and production workflow), you can disable all of the functionality that allows site administrators to install code through the administrative user interface by placing the following line in your site’s settings.php file:

$conf['allow_authorize_operations'] = FALSE;
You will still be able to run the Update manager to check the status of available updates, but you will not be able to install those updates or new modules and themes directly via the web interface.

From

https://www.drupal.org/documentation/modules/update

Filed under: development, drupal, ,

Cleat Drupal cache via SQL

A handy little bit of sql to clear the cache tables just before you back up a drupal db to sql.

Steps to follow:

  1. Replace {db_name} by the real project’s database name.
  2. Execute the sentence.
  3. Copy the generated string (TRUNCATE list, one for each table).
  4. Execute the string  copied in the previous step (TRUNCATE list).


SELECT
CONCAT('TRUNCATE TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';') AS table_name
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = '{db_name}'
AND TABLE_NAME LIKE 'cache_%'
AND TABLE_TYPE = 'BASE TABLE'

The resulting string must be something like this (will vary depending on the Drupal version and the installed modules):


TRUNCATE TABLE {db_name}.cache_admin_menu;
TRUNCATE TABLE {db_name}.cache_block;
TRUNCATE TABLE {db_name}.cache_bootstrap;
TRUNCATE TABLE {db_name}.cache_field;
TRUNCATE TABLE {db_name}.cache_filter;
TRUNCATE TABLE {db_name}.cache_form;
TRUNCATE TABLE {db_name}.cache_image;
TRUNCATE TABLE {db_name}.cache_menu;
TRUNCATE TABLE {db_name}.cache_metatag;
TRUNCATE TABLE {db_name}.cache_page;
TRUNCATE TABLE {db_name}.cache_path;
TRUNCATE TABLE {db_name}.cache_token;
TRUNCATE TABLE {db_name}.cache_update;
TRUNCATE TABLE {db_name}.cache_variable;
TRUNCATE TABLE {db_name}.cache_views;
TRUNCATE TABLE {db_name}.cache_views_data;

From

http://zonesoftware.co/en/blog/article/clear-cache-in-drupal-via-sql

Filed under: development, ,

Max Allowed Packets

The max_allowed_packet variable can be set globally by running a query.

To change the setting for everyone until the server restarts:

SET GLOBAL max_allowed_packet=1073741824;

Filed under: development,

Changing the path to site root in cpanel

For changing the main/primary domain, you will need to have root SSH access and be able to locate and edit the following file (replacing your user & domain info):

cd /var/cpanel/userdata/USERNAME/DOMAIN.COM

1. Once you have opened the file, look for the following line:

documentroot: /home/USERNAME/public_html

2. Modify the location according to your needs. Save it and exit.

3. Rebuild the Apache conf and restart Apache:

/scripts/rebuildhttpdconf
service httpd restart

http://blog.servint.net/2012/03/30/the-tech-bench-changing-a-document-root-in-cpanel/

Filed under: code snippets, development

Raspberry Leaf

A really useful idea – a template for Raspberry Pi GPIO so you can see the PIN numbers when attaching your wires.

Visit Dr Monks site for the print out.

Thanks to Liz from Raspberry Pi blog for the link.

20130218-214436.jpg

Filed under: development, raspberry pi

Scoopy – view HTML source on Mobile Safari for iPhone ad iPad

Snoopy is a bookmarklet that go can install on mobile browsers where you can’t view source. Once installed, you can get access to both source and generated source as well as information about the document.

check out scoopy

image

Filed under: development, ,

hook_form_alter

A few links relating to hook form alter
In Drupal 7. Used to modify form output .
snippets

api

Filed under: code snippets, development

Dealing with images in concrete 5

Been working with a new client today who uses the CMS concrete5.

It’s been an eventful day working out what is standard concrete and what had been modified by the client. There’s been a lot of custom work on this system, with some good improvements but this also makes for head scratching over things that might be earlier in other CMSs.

We found the onboard editor in concrete5 responsible for rescaling images no longer works as the Picnik image editing service from google has been shut down. Fortunately it looks like Picmonkey fills the space:

http://www.concrete5.org/marketplace/addons/picmonkey-image-editor/

To get images into the view, we’d use concrete5s image helper:

http://c5cookbook.com/recipes/generate_thumbnail_images

We were looking at ways to affect the jpeg quality of the thumbnail too. Seems someone has done this for us:

https://github.com/concrete5/concrete5/pull/675

Filed under: development

How to change the default crontab editor

env EDITOR=nano crontab -e

Thanks to http://www.linuxquestions.org/questions/red-hat-31/how-to-change-the-default-crontab-editor-395750/ for the tip

Filed under: code snippets, development

Dealing with wildcards in croogo

i’ve been looking into wildcards for visibility paths primarity so I can add a block into my news/view page without specifying all my news articles.

inside blocks function within croogo component, there is a query which checks the url:

'Block.visibility_paths LIKE' => '%"' . $this->controller->params['url']['url'] . '"%',

obviously, adding news/* wont match so no block in this instance.

The solution I settled on was to modify the conditions and add another check:

I replaced:

'conditions' => array(
'Block.status' => 1,
'Block.region_id' => $regionId,
'AND' => array(
array(
'OR' => array(
'Block.visibility_roles' => '',
'Block.visibility_roles LIKE' => '%"' . $this->roleId . '"%',
),
),
array(
'OR' => array(
'Block.visibility_paths' => '',
'Block.visibility_paths LIKE' => '%"' . $this->controller->params['url']['url'] . '"%',
//'Block.visibility_paths LIKE' => '%"' . 'controller:' . $this->params['controller'] . '"%',
//'Block.visibility_paths LIKE' => '%"' . 'controller:' . $this->params['controller'] . '/' . 'action:' . $this->params['action'] . '"%',
),
),
),
),

With:

'conditions' => array(
'Block.status' => 1,
'Block.region_id' => $regionId,
'AND' => array(
array(
'OR' => array(
'Block.visibility_roles' => '',
'Block.visibility_roles LIKE' => '%"' . $this->roleId . '"%',
),
),
array(
'OR' => array(
array('Block.visibility_paths LIKE' => '%"' . $this->controller->params['url']['url'] . '"%'),
array(
'Block.visibility_paths LIKE' => '%"' .
'controller:' . $this->controller->params['controller'] . '/' .
'action:' . $this->controller->params['action'] . '/'.
'type:' . $this->controller->params['named']['type'] .
'"%',
),
),
),
),
),

This then allows the addition of the following in visibility paths


controller:nodes/action:view/type:news

to get our result.

Filed under: code snippets, development, ,

what's hot

Flickr Photos

Tree graffiti

Tree graffiti

Tree graffiti

More Photos

Sponsor Mike run the Bath Half marathon

mikek on twitter

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

Follow

Get every new post delivered to your Inbox.