Skip to main content
Blog IT Information technology

Main navigation

  • Home
  • Contact us

User account menu

  • Log in
  • Register

August 2023

  1. Home
  2. Monthly Archive
  3. Monthly Archive

How to Add Dependency Injection in a Controller in Drupal 8+

Dependency Injection is a design pattern that helps decouple the different components of a software application. It is a software design pattern that helps to manage the dependencies between different components in a software system. It involves passing the required dependencies into a class, rather than letting the class create or locate them itself.

Blog IT Blog IT
1 year 7 months ago
Read More

Drupal Create Node Programmatically

Drupal is a content management system that allows you to create and manage website content in an organized way. One of the ways to create content in Drupal is by creating a node programmatically. A node is a fundamental building block of a Drupal website and represents a piece of content such as an article, a page, or a product.

To create a node programmatically in Drupal 8+, you will need to use the Drupal's Entity API, specifically the Node class. Here's an example of how you can create a basic node:

Web Developer Web Developer
1 year 7 months ago
Read More

Programmatically create a user account drupal

I know that I can programmatically create a user using the following code, in Drupal .

<?php

use Drupal\user\Entity\User;

// Create user object.
$user = User::create();

//Mandatory settings
$user->setPassword("password");
$user->enforceIsNew();
$user->setEmail("email");
$user->setUsername("username");
$user->addRole('role_name');
$user->set("field_machine_name", 'value');       
$user->save();

 

Blog IT Blog IT
1 year 7 months ago
Read More

What Is GitFlow?

GitFlow is a branching model for Git, created by Vincent Driessen. It has attracted a lot of attention because it is very well suited to collaboration and scaling the development team.

Blog IT Blog IT
1 year 7 months ago
Read More

Nesting sass

But Sass wants to make your life easier. Rather than repeating the same selectors over and over again, you can write one style rules inside another. Sass will automatically combine the outer rule’s selector with the inner rule’s.

code sass

nav {
  ul {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  li { display: inline-block; }

  a {
    display: block;
    padding: 6px 12px;
    text-decoration: none;
  }
}

code css

Web Developer Web Developer
1 year 7 months ago
Read More

Selector Lists sass

Nested rules are clever about handling selector lists (that is, comma-separated selectors). Each complex selector (the ones between the commas) is nested separately, and then they’re combined back into a selector list.

code sass

.alert, .warning {
  ul, p {
    margin-right: 0;
    margin-left: 0;
    padding-bottom: 0;
  }
}

code css

.alert ul, .alert p, .warning ul, .warning p {
  margin-right: 0;
  margin-left: 0;
  padding-bottom: 0;
}

 

Web Developer Web Developer
1 year 7 months ago
Read More

Create a Taxonomy Term Programmatically in Drupal

We know Taxonomy is a powerful core module and helps us categorize the content. A vocabulary in Drupal is essentially a container for terms that are used by the system. These terms are what Drupal uses to connect certain areas together within the website.

Web Developer Web Developer
1 year 8 months ago
Read More

How do I create a role user drupal programmatically

How do I create a role programmatically in Drupal 8+

//your data array
$data = array('id' => 'client', 'label' => 'Client');
//creating your role
$role = \Drupal\user\Entity\Role::create($data);
//saving your role
$role->save();

In my case, I wanted to be able to auto-create multiple roles ("clients","managers","salesrep") to work with my custom module.

This is how I auto-create roles programmatically in Drupal.

Web Developer Web Developer
1 year 8 months ago
Read More

Subscribe to the Newsletter

Blog Category

Web
Mobile
Security
Design

Tags keyword

html
css
php
Sass
html5
drupal
drupal 8
drupal 9
drupal 10
laravel
symfony
vue.js
vue
js
css3
jquery
javascript
image
table
iframe
link
mail
twig
drush
module
git
gitflow
web
drupal 7

Monthly archive

  • May 2018 (1)
  • May 2019 (1)
  • November 2019 (1)
  • December 2019 (1)
  • March 2020 (2)
  • May 2020 (3)
  • June 2020 (2)
  • July 2020 (3)
  • November 2020 (1)
  • December 2021 (3)
  • October 2022 (1)
  • November 2022 (7)
  • December 2022 (15)
  • February 2023 (1)
  • April 2023 (1)
  • May 2023 (2)
  • June 2023 (3)
  • July 2023 (4)
  • August 2023 (8)
  • September 2023 (3)
  • October 2023 (9)
  • November 2023 (5)
  • September 2024 (1)

Copyright © 2025 - Blog Information technology - Sitemap