This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Suppose there is service defined in the docker-compose.yml file | |
# named `mysql` but it does not have `container_name` defined so | |
# we don't know what the container name is right now | |
CONTAINER_NAME=$(docker-compose -f docker-compose.yml ps | grep mysql | awk '{ print $1 }') | |
echo "Restarting mysql container" | |
docker stop $CONTAINER_NAME | |
docker start $CONTAINER_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# | |
Don't call this method directly from templates. Rather, call the `neo` or `matrix` | |
methods to keep things future-proof. | |
Block templates may be named (from most generic to most specific) | |
{ block type }_{ entry field handle }_{ entry section handle}_{ entry type}.twig | |
{ block type }_{ entry field handle }_{ entry section handle}.twig | |
{ block type }_{ entry field handle }.twig | |
{ block type }.twig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script assumes you have ssh access to a remote server | |
# Both databases are backed up to sql files in the same directory | |
# this script is executed from. | |
# Usage: | |
# 1. Make sure this file is executable with `chmod +x mysqlsync` | |
# 2. Set the credentials for the variables at the top | |
# (Remember, no spaces around the '=' sign) | |
# 3. Run it from a directory where you'd like the backup files to go: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For Drupal multilingual sites | |
# | |
# When the first segment of the url path is a language like 'en', 'fr', 'es' | |
# paths to files break because Drupal adds them to the base url. | |
# This turns `http://site.com/es/style.css` into `http://site.com/style.css` | |
# if the latter is actually a file. | |
RewriteCond %{DOCUMENT_ROOT}/$1 -f | |
RewriteRule ^/?\w{2}/(.+)$ %{DOCUMENT_ROOT}/$1 [L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if entry is defined and currentUser and currentUser.can('editEntries:' ~ entry.id) %} | |
<a href="{{ entry.cpEditUrl }}" class="edit-this section-{{ entry.sectionId }}">Edit this</a> | |
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* NOTE: This gist is very old. You might want to check out recent forks | |
* like this one: https://github.com/Alexlytle/Wordpress_custom_route/blob/main/Wordpress_Custom_route.php | |
* (thanks @Alexlytle) If you have an improvement to this gist, please | |
* post a link in a comment for others who might benefit. Thanks! | |
* | |
* A class to create simple custom routes. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns the simple, cleaned, translated value for a node or user field | |
* without extra Drupal markup. | |
* | |
* Examples: | |
* <?php print render_entity_field('user', $user, 'field_first_name'); ?> | |
* <?php print render_entity_field('node', $node, 'field_my_custom_field'); ?> | |
* | |
* @see http://www.computerminds.co.uk/articles/rendering-drupal-7-fields-right-way | |
* @param string $type 'node', 'user' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns the simple, cleaned, translated value for a node or user field | |
* without extra Drupal markup. | |
* | |
* Examples: | |
* <?php print render_entity_field('user', $user, 'field_first_name'); ?> | |
* <?php print render_entity_field('node', $node, 'field_my_custom_field'); ?> | |
* | |
* @see http://www.computerminds.co.uk/articles/rendering-drupal-7-fields-right-way | |
* @param string $type 'node', 'user' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns the simple, cleaned, translated value for a node or user field | |
* without extra Drupal markup. | |
* | |
* Examples: | |
* <?php print render_entity_field('user', $user, 'field_first_name'); ?> | |
* <?php print render_entity_field('node', $node, 'field_my_custom_field'); ?> | |
* | |
* @see http://www.computerminds.co.uk/articles/rendering-drupal-7-fields-right-way | |
* @param string $type 'node', 'user' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get an array of users for a given role id. | |
* @param int $rid - The role id | |
* @return array | |
*/ | |
function users_by_role_id($rid) | |
{ | |
$users = array(); | |
$uids = array(); | |
$query = db_query("SELECT uid FROM users_roles WHERE rid = :role_id", array(':role_id' => $rid)); |