GSoC’ 16: Port Search Configuration module; coding week #3

Google Summer of Code (GSoC’ 16) is entering into the mid-Term evaluation stage. I have been working on the porting search configuration module for Drupal for the past three weeks.

Search configuration module helps to configure the search functionality in Drupal. This is really an important feature when it comes to a content management system like Drupal. I am almost mid-way in the port process as indicated in the timeline of Google Summer of Code.

It is really a great feeling to learn the Drupal concepts this summer. I would like to take this opportunity to share with you some key aspects I had to deal with in the past week.

Once a module is installed and later on if some changes are amended, we need not rewrite the Drupal code. Instead, Drupal gives up the option to make use of a hook, function hook_update_N which helps us to write the update needed and the database schema gets updated accordingly. Currently, since my module is just going into its first release after this port process, I need not write an update function. I just have to make this update in connection with the earlier code. The same hook works for both Drupal 7 and 8.

Another feature is the hook_node_insert, this hook is invoked to insert a new node into the database. So, here we are writing into the database a drupal record. In Drupal 7, this insertion was done by the drupal_write_record(). But,in D8, it has been replaced by the merge query and the entity API. The merge queries support the insert and update options to the database.

In connection with the nodes, another hook function is the hook_node_update. This functionality updates the node contents which has been inserted into the Drupal record (database). This takes in an argument, obviously,  the node has to be passed, for which the updating is intended.

The hook_uninstall gets invoked as the name suggests, in the uninstall process of the modules. The hook removes the variable used by the module so as to free the memory. It also modifies the existing tables if required. The D7 version of Drupal used the  variable_del for removing the variables.

For instance,

variable_del($nameOfVariable);

// Drupal 7 code

This has been replaced by the delete() of the configuration API.

i.e,

\Drupal::service('config.factory')->getEditable('search_config.settings')->delete();

search_config.settings is the default configuration file.

I will post the updates on this port process regularly. Please wait for the future posts.

Advertisements

Working with the database Part 2/2

pgadminI hope you have installed pgadmin3 from my previous post .

Now open pgadmin 3.

Add a connection to server by clicking the first option in the top of the window.

Add the details as added in the below snap:

Server Registration
Server Registration

Name is the name of the database.

Host is our localhost which is setup at 127.0.0.1

Port can be left as 5432

Maintenance DB and username is by default postgres

Add the password you have given in the postgres setup in the password field.

Click OK and you are done with server connection.

Go to the database you have created and start exploring through SQL queries.

Thanks for reading.If you have any issues/doubts,feel free to comment or drop me a mail at geojoyce934@gmail.com

Have a nice day.

Working with the database Part 1/2

Recently I was installing PostgreSQL and related tools.So,I decided to share you my experience and help you to establish the same.

We are currently having Database Managment systems(DBMS in short) for our semester 5 B.Tech course.We are following the PostgreSql and pgadmin3 as the interface application.So,I hope this post will definitely help my friends in installing the PostgreSql and the related tools in handling it.

Initially,I recommend everyone to have Apache installed in your system.Localhost is a very cool service which will help you to host things and apache establishes it and localhost will be useful as a host in the pgadmin process.

So,lets get started Ctl+Alt+T

As the terminal comes up,enter the command:
sudo apt-get install lamp-server^

This will help you install the LAMP(Linux Apache Mysql Php) in ubuntu.Mysql is also another sql database.If you go to 127.0.0.1 in your browser you will see the localhost page.You will probably get something like this given in this below snap.

127.0.0.1
127.0.0.1

Once it is done,lets move into the postgreSql part.
To install PostgreSql,enter
sudo apt-get install postgresql postgresql-contrib

Now,we need to setup it.Enter,
sudo -u postgres psql postgres

You are now in the postgres.Add a password to your postgres by entering

\password postgres

You will be prompted to enter the password once you enter the above command.
To create a new database enter:
sudo -u postgres createdb db

where db is the database name
To exit the postgres,enter Ctl+D or \q

Now,to install pgadmin.

sudo apt-get install pgadmin3

I think this post is getting a bit longer.So.working with pgadmin in my next post.

See you guys.

Have a nice time.