Skip to main content

Welcome to Key2Goal

It's a Tech Blog
hero-image
techoptions-img

Blog Posts

techoptions-img
CSS

hey, below you can find the simple example of centering a div vertically and horizontally using css

techoptions-img
Other

hey, Here you get how to subtract to date in angularjs with core functionality

techoptions-img
Drupal

If you know how to make a content type template in drupal 7 then you can easily understand in drupal 8, Here there is not much change except that the template is in twig format. 

For creating the content type template in drupal 8 you have to do two things :

1) Add this code in your mytheme.theme file in your working theme folder :-

techoptions-img
Drupal

Drupal 8 gives the flexibility to make menu template and design the menu with our need, to do this --

techoptions-img
Command line

hey guys,

If you want to create the snapshot daily of you aws instance this article is for you, previously I was use aws cli to make snapshot daily using linux cron, but few months back I found a script by caseylabs on github, following url will get you there or attached zip will also work, I recommend that download and install from URL:

https://github.com/CaseyLabs/aws-ec2-ebs-automatic-snapshot-bash

techoptions-img
Command line

Usually we all use "rm" command to delete or remove the files and folder on linux, but if we want to delete the specific type of content/files then we can use "find" command to find and "delete" command to delete;

find . -name "*.zip" -type f -delete

or enter path of directory

find /path/to/dir -name "*.zip" -type f -delete

if you to get list of all items of specfic extension you can do like this before delete -

find . -name "*.zip" -type f 

or

ls -la *zip
techoptions-img
PHP

Sometimes we get this php error on long page load or load many files are at once

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 54 bytes)

This is because of memory_limit parameter of php.

If you have sufficient RAM available on server your used you can change this parameter on php.ini

change this - 

memory_limit = 128M

TO

memory_limit = 1024M

techoptions-img
PHP

n PHP sometimes we need to find the specific word in the string for the programitically use the code, there is a function called "strpos()" will help to do this.

example:

 

$string = 'this is website name is key2goal';

if (strpos($string, 'key2goal') !== false) {
    echo "Found";
}

Please Comment your thoughts and feedback below and add something if you found good in anywhere to help others

techoptions-img
Drupal

If you are getting permission error while installing CiviCRM on xampp then, its is default CiviCRM user permission error,

Just comment the following code in "sites/all/modules/civicrm/install/index.php" See Below:

Find below code on index.php usually at line no 268, comment the whole If condition :

techoptions-img
Drupal

As we know drupal 8 use symphony, so module structure of drupal 8 is change and workflow functionality of doing thing also change. we can make Drupal 7 module procedure oriented but in drupal 8 module needs to follow object oriented MVC architecture.

In this tutorail we learn how can we create the node programmatically in drupal 8 with image upload using custom module.

Let say module name is "nodecreator"

1) To Create a module we need a nodecreator.info.yml file

techoptions-img
Command line
Install Apache Solr 7.7 on Ubuntu 18.04 & 16.04 LTS

This tutorials explains how to install solr 7 on ubuntu system

1) Install or Check Java

Apache solr 7 required java to run there application on the server. Verify java is installed or not on server first using command:

java -version

Result :

techoptions-img
Drupal

hey, For many purpose we have to print the array or object while making a custom modules or debuging any old module, we have to print the array or object to see the values are fine or not, drupal provide a way to see those using watchdog, But how we print array or object in watchdog function, Answer is below.

watchdog("any_word_you_like", '<pre>' . print_r( $your_object_variable, true) . '</pre>');

Now, execute your function or page whenever you right it.

Then go to - https://yourdomian/admin/reports/dblog

techoptions-img
Drupal

Hi guys,

In this tutorial we can see how we can send files as attachments in drupal 7 on webform submit using a hook_mail_alter 

1) For this we need Mime Mail module and webform module

2) Create a simple module and use hook_mail_alter like below, In my case "attach_web" is my module name

techoptions-img
Drupal

If you want to render the menu items in custom way in page or node twig template of drupal 8 then this article is for you :

 

At man place where you make the template in drupal theming you want to render your menu in different style, For example main menu at header shows in different style while in footer in different style, for that you need to code on twig template but you don't know much about twig the simply use this module called "simplify menu"

 

techoptions-img
Drupal

Render a Drupal node in drupal 8 twig template and module PHP code is a bit different from Drupal 7 because Drupal 8 uses Symfony and twig format, follow the step and you will available to render a node in Drupal 8 templates 

Step 1.

create hook_preprocess_page in your yourtheme.theme file 

and paste code (rename your theme name at the place of hook)

$nid = 130;
$entity_type = 'node';
$view_mode = 'teaser';

techoptions-img
Drupal

This is article is for Drupal 7 to render block in templates and custom blocks using php codes

Actually there is very simple ways to render block pro-grammatically 

1) Module Invoke

$block = module_invoke('module_name', 'block_view', 'delta or machine name of block');
print render($block['content']);

Module invoke is most common way to render a block, above example is self explained or see the below example

techoptions-img
PHP

Sometimes we need to slice the array for certain values using program a code and at that time key of array is also unset.

If you faced the same then you can use these options

$reindexed_arr = array_values($arr);

you can also try these function in PHP

techoptions-img
Command line

Self Signed certificates are those are signed by the same individual whose identity it certifies. It usually creates for personal use or trusted use only like server login using the key file or for SAML use for website user login, there are different use of it, so let see how it will create with Linux / centos command prompt.

Firstly check if you have OpenSSL installed or not for that use command

openssl version

techoptions-img
Command line

I have faced this error recently , look like this 

 

Warning in ./libraries/sql.lib.php#601

count(): Parameter must be an array or an object that implements Countable

 

This warning comes again and again when you try to access phpmyadmin databases tables ,

below solution I tried may be got help to you also :

OPEN THE BELOW FILE

/usr/share/phpmyadmin/libraries/sql.lib.php

and search for this line 

techoptions-img
Command line

If you want to Install Multiple PHP version on ubuntu/Linux system then this tutorial is for you.

and on ubuntu shell using root user and follows steps below:

1) check and Update the repository cache of ubuntu.

sudo apt update

2) Install required Packages

sudo apt install -y curl wget gnupg2 ca-certificates lsb-release apt-transport-https

3) Add repository for mutiple php