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):

drush updb

After running "drush updb", you should next run entity updates command:

drush entup

or

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

How to check if your drupal site was hacked (and how to fix it)

Install drupalgeddon on your server:

drush dl drupalgeddon

Install Site Audit:

drush dl site_audit --dev

Install Hacked:

drush dl hacked --dev; drush en hacked -y

Install Security Review:

drush en security_review -y

OPTIONAL: run all the above in a single line.

drush dl drupalgeddon -y; drush dl site_audit --dev -y; drush dl hacked --dev -y; drush en hacked -y; drush en security_review -y

Run the drupalgeddon site audit--this will also run the above modules--this will create a file called 'report.html'. Open it up and see what's up.

Tags: Drupal hack security drupalgeddon

Drupal Drealty How to fix Active Properties Set to 'active=0'

Sometimes drealty doesn't properly set RETS status properties marked as "Active", "Pending Sale", or "Backup Offer" as 'active=1'. Any property marked as 'active=0' will NOT display, no matter what 'rets_status' is marked as.

We can fix that by running this SQL query in phpMyAdmin:

UPDATE `drealty_listing` SET `active`='1'
WHERE `rets_status`='Active' or `rets_status`='Pending Sale' or `rets_status`='Backup Offer' ;
Tags: Drupal drealty

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:

'#delta' => 10

Replace with this:

'#delta' => 60
Tags: Drupal Views module

How to install Composer and Drush LOCALLY and GLOBALLY

Drush 9.x Install Composer to your LOCAL user directory

cd ~
mkdir .composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar ~/bin/composer
chmod +x ~/bin/composer
echo "PATH=$PATH:~/.composer/vendor/bin" >> ~/.bash_profile
. ~/.bash_profile

Install latest version of Drush locally

Get the latest (or whatever) version here:

https://github.com/drush-ops/drush/releases

cd /LOCATION/OF/DRUPAL
composer require drush/drush

And we done...

Tags: Drupal Administration Linux drush composer

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:


# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# uncomment the following:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^(subdomain1|subdomain2|subdomain3)\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

So what changed? We simply added this line:

Tags: Drupal Linux admin

How to install GEOS on CentOS and directadmin

cd /usr/local/src
wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2  # go here to find the latest version: http://download.osgeo.org/geos/
tar -xvjf geos-3.4.2.tar.bz2
cd geos-3.4.2
./configure --enable-php; make clean ; make
make install
ldconfig
vi /etc/ld.so.conf

Add the following line if it doesn't already exist

/usr/local/lib

Find the location of the newly installed geos.so

updatedb
locate geos.so

You'll get something like this:

/usr/local/lib/php/extensions/no-debug-non-zts-20090626/geos.so

Add the extension info to your php.ini

vi /usr/local/lib/php.ini

Add the following (somewhere around the rest of your extension, e.g. APC):

For PHP 5.3:

Tags: centos geo Geocoder Geofield Drupal

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...

Install latest version of Drush


cd /usr/local/share
# install GIT if not available
yum install git
git clone https://github.com/drush-ops/drush.git drush
ln -s /usr/local/share/drush/drush /usr/local/bin/drush
drush

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 / )


cd /usr/local/share

Download Apache Solr. We're going to use the latest version at the time of this writing: Apache Solr 3.5. Look for the latest version here: http://www.apache.org/dyn/closer.cgi/lucene/solr/

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

vi /usr/local/lib/php.ini

Add the following to your extensions section:

extension=uploadprogress.so

Restart apache

service httpd restart

Here are additional steps you may need to take: https://www.drupal.org/node/2718253#comment-11159883

Or if you are using PHP 5.X:

Tags: Drupal linux server media