Blogs on

Drupal planet

knackforge blog

Drupal form's #tree option

There may be a need to name the form elements in an array structure how the form is built. You can see this in Ubercart checkout pane form's input elements. This is very useful when one has a large multi-part form which can be grouped easily by their POST content's array format.

Eg: panes[delivery][delivery_first_name]

A simple flag on you $form construct array will do the trick. It's the #tree option. For whichever elements you set this #tree option, the element's children will be named with full reference to its parents.

Continue reading →
knackforge blog

Drupal Commerce - PayPal payment was successful but order not completed

Most of us use PayPal as a payment gateway for our eCommerce sites. Zero upfront, No maintenance fee, API availability and documentation makes anyone easy to get started. At times online references offer out-dated documentation or doesn't apply to us due to account type (Business / Individual), Country of the account holder, etc. We had this tough time when we wanted to set up Auto return to Drupal website.

Continue reading →
knackforge blog

How to create Queue woker in Drupal 8

The queue API allows placing items in a queue and processing them later. If you have a task that must be done regularly and it takes more time to complete then Cron queue might be the better solution. 

In Drupal 8, hook_cron_queue_info() has been replaced by QueueWorker Plugin. Define the queue worker by creating QueueWorker folder inside Plugin folder. In the below example, I create a form for sending the email. Emails will be added to the queue on submitting the form. On cron run emails will be dequeued.  

src/Plugin/QueueWorker:

Continue reading →
knackforge blog

How to make Apache solr search programmatically from Drupal 7

Recently I came across a situation where I needed to make Apache solr search from drupal programmatically. Basically we have Apache solr module available in drupal, which enables to connect with solr for searching. There are loads of documentation for setting solr search with drupal, so instead going into those details, lets head straight to the custom code required to make programmatic solr search from drupal:

Continue reading →
knackforge blog

Review of Drupal professional themes

DropThemes.in is one among the best Drupal professional theme selling sites. With decades of free theme and quality of paid themes, DropThemes.in has got its own place in the list professional theme selling sites. All our themes are Responsive and catered specifically for Drupal sites. A good theme gives your website a distinct feel that sends out a positive impression to your visitors. In this post, we would like to review the top themes on DropThemes.in to help you select the best.

Continue reading →
knackforge blog

Create single page site in drupal 8 within 15 minutes

We all know that the Drupal setup and installation are easy, and one click installation is also available in most of the hosting services, but the tricky part is theming the drupal site. It would take some time to design the site to make it look more professional.

In this blog, I am going to show you how to build a single page drupal site within 15 minutes with a good looking theme.

Continue reading →
knackforge blog

How to delete an order if the order is in cart for N days

In drupal commerce, the order will be created when a product is added to cart and the order will exist until the order is deleted or order status is changed to completed.

We have an e-commerce site in which most of the orders are idle in the shopping cart. So we decided to delete the order if the order is in the shopping cart for more than 'N' days or weeks. I have written a custom drush command for deleting the order.

The following code is used to delete an order if it is in the cart for more than 25 days.
 

Continue reading →
knackforge blog

Programmatically create and trigger feeds importer

We met with a challenging requirement where we needed to create a feeds importer on node creation of particular content type. It’s like for ‘n’ number of nodes there must be a ‘n’ number of feeds importer.

For that I created a feeds importer which will be considered as the template. Whenever the node of specific content type is created, the template will be cloned and a new importer will be created.

The following code needs to reside in hook_node_insert() and will be used to clone the feeds importer:

Continue reading →