Drupal

HOW-TO: create a Drupal views block to display the current node content

In views section, for an existing view or newly created one, do the following:

  1. Click "Add" > "Block"
  2. Fill in whatever you normally would do in views (this is beyond the scope of this tutorial)
  3. Under "Contextual Filters" > click "Add" >  "Content: Nid" > "Provide default value" > "Content ID from URL"

And that's that... 

Tags: Drupal Views

Drupal 8 drush critical update commands

There are some new drush Drupal 8 commands that are critical to updating your site. The big new one here, is "drush entitity-updates".  Which should be initiated AFTER "drush updb".

Otherwise, if you check your Drupal 8 "Status Report" you may get an error showing "Entity/field definitions: Mismatched entity and/or field definitions"--which won't be apparent, unless you check the Status Report.

So here goes... 

Clear all cashes (no longer "drush cc all"):

drush cr 

or 

drush cache-rebuild

Update the database (this is still the same, however, you won't be done here):

Tags: Drupal drupal 8 drush

How to install Apache Solr 5.x for use with Drupal

Here's the updated version on how-to install Apache Solr 5.x and get it running with Drupal (WITHOUT Apache Tomcat; as Solr 5.x doesn't support Tomcat anymore).

Install Java 1.8

yum install java-1.8.0-openjdk.x86_64
# or
aptitude install java8-jdk

Create a symlink to wherever your /etc/bashrc or ~/.bashrc has export JAVA_HOME=/usr/local/jdk set to.

Tags: apache apache solr Drupal Server admin

Drupal remove deleted fields from database

Install and enable Field SQL norevisions, and use it to delete any revisions you don't need. Also set it to disable revisions for content/entity types that you don't want revisions being made.

Note: For entity content types, drupal will automatically make revisions for each update, but won't allow you to revert to any of these revisions, so this is pretty pointless; plus for very large databases this can degrade performance.

Tags: Drupal drush

Increase Limit of Drupal Views Exposed Group Filters sort order

My original post: Exposed filters group: increase weight sort count (#delta)

This still hasn't been fixed at the time of this writing. So here we go...

Sort breaks, and does unpredictable sorting, if you use more than 20 options. E.g. say you have have an exposed grouped filter with a price drop down of more than 20 options, sorting will not work after 20 items, it will always spit out a different order than what you specify.

The fix

Edit the following Views module file:

sites/all/modules/views/handlers/views_handler_filter.inc

Look for this:

Tags: Drupal Views module

Drupal .htaccess rewrite with 'www' but not for sub-domains

Say you have your Drupal's .htaccess set "To redirect all users to access the site WITH the 'www.' prefix", and you added a sub-domain, and it came out looking something like http://www.sub.domain.com. So, most people will NOT want the "www" added to the url in this case. So what do you do? Easy.

Use this instead:

Tags: Drupal Linux admin

Upgrade Drupal 6 to Drupal 7 using Drush site-upgrade

Ok... So you decided that it's time to upgrade from Drupal 6 to Drupal 7. It's not going to be easy, but using Drush will make life a little easier.

What this will do is save you the time of manually upgrading Drupal 6 core and drupal 6 modules to Drupal 7 core and drupal 7 modules. Of course likely your site will be broken after the drush site-upgrade, but at least you have the manual job of searching for upgraded modules taken care of.

So, let's begin...

Tags: Drupal drush

How to set a custom sub-domain path in DirectAdmin

UPDATE: See below, there's an easier way to do this. Plus DirectAdmin's way doesn't seem to be working through the 'Custom HTTPD Configurations' way.... So, just use the way listed below. It's much easier.

*** OLD WAY / start ***
I work with Drupal's Domain Access module a lot. However, if you're using DirectAdmin as your hosting control panel, then making sub-domains will not work with the default setup. DirectAdmin puts the sub-domain into a separate directory, and in order for Domain Access to work with sub-domains on DirectAdmin, this needs to be set as the same directory/path as the top domain.

A simple work around is to login to DirectAdmin as administrator, and go into "Custom HTTPD Configurations".

Here you will paste the following code:

Tags: DirectAdmin Linux Drupal Domain Access

How to install Apache Solr 3.x for Drupal 7 or Drupal 6

First we'll need to install Java 1.6 JDK, and be on PHP 5.2 or higher (You can check my PHP installation tutorial here. Also I'm on CentOS.

Install Java 1.6 JDK

yum install java-1.6*

Install Apache Solr

We're going to install Apache Solr into /usr/local/share; however you can install it somewhere else if you'd like (e.g. install it in the root dir / )

Tags: Server Drupal linux server apache solr solr

How to place drupal blocks anywhere in content.

If you're looking to place a block anywhere inside your content, simply do the following:

go to /admin/build/block

select the block you want to insert into your content to get the proper block references...

e.g. I created a custom views block called "latest_news" which, if you click it's url looks like:
/admin/build/block/configure/views/latest_news-block

so basically, you'll use "views" at the beginning of the function reference and "latest_news-block" at the end:

Drupal 7 method

Menu block

Tags: Drupal blocks

Drupal: How to create a View that shows results only from the current node

Let's say you want to create a Views block that shows on a bunch of different pages/nodes that have multiple (imagefield) images per page, and you want the block to dynamically display ONLY the images from the particular node you're on--and not display images from other nodes.

This is how you would do it:

1. Create your view as you normally would.
2. Add "Node: Nid" under "Arguments".
3. Select "Provide Default Argument" under "Action to take if argument is not present:"
4. Select "Node ID from URL" under "Default argument type:"
5. Leave everything else as is...
6. Hit "Update" and then "Save"... and you're done.

Tags: Drupal

How to add custom javascript into the drupal webform module <form> <submit>

Recently, one of our clients asked to have custom tracking code implemented into their form submissions.

Since the client's site is built on Drupal, all forms are dynamically generated using the Webform module.

Their marketing company instructed us to add an 'onclick' code to :

<input type="submit" class="form-submit" value="Receive Coupons" id="edit-submit" name="op" onclick=tracking("track_submit_quote") />

However, since the Webform module creates all forms dynamically, there was no convenient way of hard coding the code into the form... i.e. there was no way for this to be done via webform admin.

Tags: Drupal module

How to install PECL uploadprogress w/ PHP 7 support

Original uploadprogress doesn't seem to be developed any longer, and hence doesn't support PHP 7. However, there's a PHP 7 compatible version we can use:

cd /usr/local/src/
git clone https://github.com/Jan-E/uploadprogress.git
cd uploadprogress
phpize
./configure
make
make install

Now add the extension to your php.ini

Tags: Drupal linux server media