Skip to main content

Welcome to Key2Goal

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

Blog Posts

techoptions-img
Other

search engine crawlers are very required to reach audience to your website, but if they hit continuous it will harm your website performance, If you want to prevent search engine crawler to crawl here is first and basic way to do that i.e. robot.txt

robot.txt is file which tells crawlers to what part of your website need to crawl and what part or directory not, but in written format, robot.txt follows a format to let the crawls bots to performs on your website, it also block  and allow different bots by there names

techoptions-img
Command line

Webmin is open source control panel for linux machine, it is mainly use for server as file transfer, email configuration and other servers configuration using modern user interface.

Here is the step to install the Webmin on ubuntu

1) Open the command prompt of your server and switch to root user

2) Now add webmin repository to source list file using command or any editor

vi /etc/apt/sources.list

and add this line at bottom of file 

techoptions-img
Drupal

Hi guys, In this article we see how we can make custom form with a menu link in drupal 8. Some of criteria of creating is changed form drupal 7 but it is quiet to understand the new setup, so let's start

For this we need to create a custom module so create a folder and make info.yml file 

1) Create modulename.info.yml file

2) Create routing.yml file for menu link and define the form page

3) Create the src/form folder and under it create "CustomForm.php" that we define under our routing file.

techoptions-img
Drupal

Are you looking for how to load node and node fields using nid to into your custom work, then this article is helps you to achieveing this.

Node is just entity in drupal and in drupal 8 entity is loading new way using function "entityTypeManager()"

entityTypeManager()

Below is the example how to load the node using nid

techoptions-img
Command line

Hi, this article is related to bash tab completion is not working for specfic user on ubuntu/linux systems.

are you also facing the same, then this article is for you

The reason may be is that you create the new user for the system with /bin/sh and that user pointing to /bin/sh instead of /bin/bash after login.So you can change user's login shell with the 'chsh' command

sudo chsh -s /bin/bash <username>

And if you still getting the issue with root user also then you should do simpily

techoptions-img
Drupal

Hi Guys, today topic is markup element of form api drupal 8. As we know the form api is describe the how the actually it can we used under development process, but recetry I found that markup element is missing form drupal 8 form api, so what if we need to display custom html with custom form then we can use the alternative as i show below.

In Drupal 7 there is specfied element in form api for markup, many of you used this before 

techoptions-img
Drupal

In this Tutorial we learn how to make a a custom block and render a form in a block in drupal 8 customization process.

So lets start 

1) Create a basic simple module by create .info.yml file as below:

name: Custom form in Block
description: key2goal example module for form in block
type: module
core: 8.x
package: Custom

2) Now create the form in src/Form/KeyForm.php as below:

techoptions-img
Command line

Hi guys,

Did you faced the this issue while configuring the apache on your server, then you are on the right totorial,

Error: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using example.com. Set the 'ServerName' directive globally to suppress this message

Solution:

you need to set the Global ServerName Directive for your apache configuration, apache use this map incoming HTTP requests to an IP address

Just follow the step, 

1) IF you are on ubuntu OS 

techoptions-img
Command line

To unzip the files in other directory on same folder or other folder destination you can use the command:

unzip yourzip.zip -d /path/to/your/directory

 

techoptions-img
Drupal

Similar to drupal 7, Drupal 8 also provide the logging functionality but little different to use it because the drupal 8 is symphony base architecture, so can use the logger service of drupal 8 to reload your logs on dblog

For Notice type:

<?php
\Drupal::logger('module_name')->notice($message_string);
?>

For Error Type:

techoptions-img
Drupal

his 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
Javascipt

HTML5 video playing on any web page is very easy, in this tutorial we can show you how to add video on html and make it play and pause without using html controls. I personally use this  play pause because many times we are using video to play auto animation to website

Below is the code and embed codepen to show its works:

techoptions-img
Other

If you get the same error like below in VScode editor then you are the right place to 

"PHP executable not found. Install PHP 7 and add it to your PATH or set the php.executablePath setting"

 

Solution: this error is shown because the PHP IntelliSense extension in VScode editor.

1) To solve this open setting button or go to file -> preferences ->  settings

2) Search php and select PHP IntelliSense like below Image

 

techoptions-img
Drupal

In drupal 8 there is easiest way to add the date format is simply go link for your website

"https://www.yourdomain.com/admin/config/regional/date-time"

OR

navigate to "Home  Administration  Configuration  Regional and language"

 

techoptions-img
Command line

Download Putty - Click Here

To Transfer files and Folder between to computer or remote server using putty .pem or .ppk file is easy.

scp is common and best way to transfer files and folder between to remote servers or local machine.

copy file from one to another system:

scp -i mykey.pem somefile.txt username@my.ip.address.xx:/path/to/paste

 

techoptions-img
Drupal

In the new era the drupal8 twig is introduce, so old basic php drupal hook is not useful in theme templates. Now twig is power under the template and if you want to know the user is logged in or Not you can use the following method in your template like node.html.twig or html.html.twig or page.html.twig etc 

{% if logged_in %}
 !!!! do you stuff !!!
{% else %}
 !!!! do you stuff !!!
{% endif %}

Its Just a simple thing helps to add script, or your static html or dynamic coding 

Happy Coding, Have Fun

techoptions-img
Drupal

Hey guys, 

Sometimes we created the themes template in drupal 7 and we need to render custom blocks and views block to display proper diversion, but I face a problem to render block in multilingual site it show the same in both languages.

So I found the solution, hopes it helps to other also 

$block_id = 2;
$block = block_block_view($block_id);
$block['content'] = i18n_string(array('blocks', 'block', $block_id, 'body'), $block['content']);
print render($block['content']);

Just need to update the $block id with yours.

techoptions-img
Drupal

Similar to Drupal 7, Drupal 8 also gives the customization using theme template, If you want to place a block using programmatically you have following options : 

1) Using the default Drupal method using THEME_preprocess_page,write this function in your mytheme.theme file, See the example below :

techoptions-img
HTML

Facebook is Providing autoposting functionality using website application and provides to display you website content on your facebook page.

But the Question how we can customise that post so it look right on page ?

Answer is Facebook Open Graph Tags.

techoptions-img
Drupal
If we need to use the php variable in our js file we can use Core Drupal.settings Functionality :

 example:

Let we assume we want to use at the page load so, add this is hook_init():

function mymodule_init(){

$token_value = "this is value of your variable";

drupal_add_js(array('mymodule' => array('token' => $token_value)), array('type' => 'setting'));

}

Now get the in your js file, but make sure your js file also preloaded to website via theme.info or any other way ...