This file contains hidden or 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 | |
// Autoload Url and Link classes. | |
use Drupal\Core\Url; | |
use Drupal\Core\Link; | |
/** | |
* External link | |
*/ | |
$url = Url::fromUri('https://colorfield.be'); |
This file contains hidden or 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
$('html').removeClass(function (index, css) { | |
return (css.match (/\bpage-\S+/g) || []).join(' '); // removes anything that starts with "page-" | |
}); |
This file contains hidden or 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
#add 'node_modules' to .gitignore file | |
git rm -r --cached node_modules | |
git commit -m 'Remove the now ignored directory node_modules' | |
git push origin master |
This file contains hidden or 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
select.form-control + .chosen-container.chosen-container-single .chosen-single { | |
display: block; | |
width: 100%; | |
height: 34px; | |
padding: 6px 12px; | |
font-size: 14px; | |
line-height: 1.428571429; | |
color: #555; | |
vertical-align: middle; | |
background-color: #fff; |
This file contains hidden or 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 | |
// Credit to Gábor Hojtsy | |
// http://hojtsy.hu/blog/2015-nov-11/drupal-8-multilingual-tidbits-19-content-translation-development | |
use Drupal\node\Entity\Node; | |
// Load node 4. In terms of language, this will get us an entity | |
// in the original submission language. | |
$node = Node::load(4); |
This file contains hidden or 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
List all containers (only IDs): | |
docker ps -aq | |
Stop all running containers: | |
docker stop $(docker ps -aq) | |
Or this one: | |
docker-compose down --remove-orphans | |
Or this one: |
This file contains hidden or 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
<div class="container"> | |
<img src="img_snow_wide.jpg" alt="Snow" style="width:100%;"> | |
<div class="bottom-left">Bottom Left</div> | |
<div class="top-left">Top Left</div> | |
<div class="top-right">Top Right</div> | |
<div class="bottom-right">Bottom Right</div> | |
<div class="centered">Centered</div> | |
</div> | |
/* Bottom left text */ |
This file contains hidden or 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
attributes.addClass() | |
Adds classes or merges them on to array of existing CSS classes. | |
Single class: | |
<div{{ attributes.addClass('my-class') }}></div> | |
Multiple classes: | |
{% | |
set classes = [ | |
'red', | |
'green', |
This file contains hidden or 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
SELECT * FROM key_value WHERE collection="system.schema"; | |
UPDATE key_value SET value='s:4:"8003";' WHERE collection="system.schema" AND name="mymodule"; | |
How to "revert" a custom module's update 'N value' | |
D7 only: If you need to execute an update hook another time when testing it locally you can "revert" a custom module's update 'N value' with: | |
UPDATE system SET schema_version = [last_successful_update_ID] WHERE name = '[name_of_module]'; | |
Replace the square brackets plus its content. See https://drupal.stackexchange.com/a/69841/19480. | |
Examples: |
This file contains hidden or 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
// Logs a notice | |
\Drupal::logger('my_module')->notice($message); | |
// Logs an error | |
\Drupal::logger('my_module')->error($message); | |
// Logs an info | |
\Drupal::logger('my_module')->info($message); |
OlderNewer