How to Fix Drupal Mysql error - Communication link failure: 1153 Got a packet bigger than 'max_allowed_packet' bytes
Introduction While this topic may applicable to all mysql/mariadb users who…
May 07, 2020
Twig is a powerful template engine for php. Drupal uses it heavily.
Lets look at some of the most useful methods and their syntax.
{% raw %}
{% set product_title = "Some value" %}
{% endraw %}
If you want to assign value to a variable from some object.
{% raw %}
{% set product_title = "#{paragraph.getTitle()}" %}
{% endraw %}
Say, I have a rendered string and I want to strip html tags from it. And, finally trim it. In this example, you will also see array usage.
{% raw %}
{% set my_code = content.field1[0] | striptags | trim %}
{% endraw %}
{% raw %}
{% if content.field_usa_code[0] %}
{% set usa_code = content.field_usa_code[0] | striptags|trim %}
{% endif %}
{% endraw %}
{% raw %}
{% set link_india = "https://www.xyz.com/#{india_code}/?param1=#{india_code}" %}
{% endraw %}
Here, I’m using variables inside a string. Take a look at its alternative below.
{% raw %}
{% set link_india = "https://www.xyz.com/" ~ (india_code) ~ "/?param1=" ~ (india_code)" %}
{% endraw %}
{% raw %}
{% set amazon_link_usa = "https://www.xyz.com/?param1=" ~ (product_title | slice(0,50) | url_encode) ~ "¶m2=#{usa_code}" %}
{% endraw %}
Here, I’m trimming the big string to 50 character max. Even if string is small, this code works. And its using another function url_encode to url encode a parameter to http query.
Introduction While this topic may applicable to all mysql/mariadb users who…
Introduction I have my main website, which I run on Lets say: . Now, there is my…
Introduction I have a host running mysql (not on a container). I have to run an…
Introduction In this post, I will show several ways to use conditionals while…
You have drupal 7 image from docker hub, and want to connect tomongo db via php…
Introduction In this post, we will see ways to look at git history logs. For…
Introduction In this post we will see following: How to schedule a job on cron…
Introduction There are some cases, where I need another git repository while…
Introduction In this post, we will see how to fetch multiple credentials and…
Introduction I have an automation script, that I want to run on different…
Introduction I had to write a CICD system for one of our project. I had to…
Introduction Java log4j has many ways to initialize and append the desired…