Drupal

Blog

Override language domains configuration locally in drupal 8

When a drupal site has different domains for its language, difficulties can arise when developing locally. With this snippet, you override your language settings, so prefixes are used instead of domains.

Blog

Allow markup inside drupal 8 Link function

Always try to use the core functions for linking inside custom formatters or modules. The following snippet allows html inside the link text.

Blog

Fix menu block showing up even when no subitems in drupal 8 bug

I personally like using the drupal menu block module. It allows for quick creation of submenu's. The following patch fixes a bug that keeps showing regions, even when there are no subitems in the menu block.

Blog

How to set the node created date when importing nodes in Drupal 8

<pre>
<code>$date = strtotime($importObject-&gt;created_at); // which is a date format
$node-&gt;set('created', $date);
// $node-&gt;save(); etc</code></pre>

<p> </p>

Blog

Save node body text html programatically in drupal 8

When saving nodes programmatically, you probably want to set the body to accept html. it is important to set the input format, so html is accepted.

Blog

Get or set your site uuid with drush in drupal 8

<p>From time to time it comes in quite handy to import configuration from other websites into yours. You site uuid is unique though, with the following snippet you get yours.</p>

<pre>
<code>drush config-get "system.site" uuid</code></pre>

<p>To set the uuid in drush:</p>

<pre>
<code class="language-bash">drush cset system.site uuid 9b13adbf-0da5-4937-a731-xxxxxxxxxxx -y</code></pre>

Blog

Get current language programmatically in Drupal 8

<p>The following snippet will return your langcode f.e. 'en', 'nl', etc. Use the following code:</p>

<pre>
<code>// Get current language code
$language = \Drupal::languageManager()-&gt;getCurrentLanguage()-&gt;getId();</code></pre>

<p> </p>

Blog

Set admin password using drush in drupal

I started using an automated script for my drupal installation, which will generate an admin user. But, after installation I have to edit the password.

Blog

Create system menu link subitem programmatically in drupal 8

I like a good user interface for webmasters, so a clear menu path is necessary. For the admin toolbar dropdowns, I usually create subitems programmatically. 

Blog

How to debug and enable php error reporting in drupal 8

While there are many ways to debug your errors, sometimes just seeing the full errors in your screen works best.

Subscribe to Drupal