How to get the field_image path with Twig in Drupal 8

In your Views:

1.Add your image filed to the Advanced/Relationship

2.Then in the filed section, change to File Group, you can see URI field,add it, and make sure you check “Display the file download URI”

3.Add your new field in the twig template: {{ fields.uri.content }}


Apache Solr Essentials Book, Reviewed by me

Leverage the power of Apache Solr to create efficient search applications

About the reviewer

install Apache Solr 4.x for Drupal 7

Install Java 1.8 JDK

yum install java-1.8*
mv apache-solr-4.10.2 apache-solr
tar xvfz apachesolr-7.x-3.x-dev.tar.gz

Now we are going to rename all the default Apache Solr config files

cd apache-solr/example/solr/conf/
mv schema.xml schema-01.xml
mv solrconfig.xml solrconfig-01.xml
mv protwords.txt protwords-01.txt

Next we’ll copy (and rename) all the Apache Solr Search Integration Drupal module config files into our Apache Solr installation at /usr/local/share/apache-solr/example/solr/conf/.

cp /usr/local/share/apachesolr/solr-conf/schema-solr3x.xml ./schema.xml
cp /usr/local/share/apachesolr/solr-conf/solrconfig-solr3x.xml ./solrconfig.xml
cp /usr/local/share/apachesolr/solr-conf/protwords.txt ./
cd pache-solr/example/
java -jar start.jar

Start Apache Solr automatically

vi /etc/init.d/solr

Paste this code (hit i key, and then paste via CTRL-SHIFT-V, or CTRL-V, or CMD-V — it all depends on your SSH client):

# Starts, stops, and restarts Apache Solr.
# chkconfig: 35 92 08
# description: Starts and stops Apache Solr
JAVA_OPTIONS="-Xmx2048m -DSTOP.PORT=8079 -DSTOP.KEY=mustard -jar start.jar"
case $1 in
        echo "Starting Solr"
        cd $SOLR_DIR
        echo "Stopping Solr"
        cd $SOLR_DIR
        $JAVA $JAVA_OPTIONS --stop
        $0 stop
        sleep 1
        $0 start
        echo "Usage: $0 {start|stop|restart}" >&2
        exit 1

assume your apache solr located in


Now that’s done, we set the permissions and make our Apache Solr start automatically and shut down properly on reboot.

chmod 755 /etc/init.d/solr
chkconfig --add solr

And here are the available commands:

service solr start
service solr stop
service solr restart

Let’s start it

service solr start

Now you can

Install Drupal Solr module

Download and install Apache Solr Search Integration module as usual. It should install successfully. You can go and mess around with the settings and indexing or do that shit later after we’re fully done with the install…

configure drupal 7 to use MongoDB

update your settings.php file with the following:


$conf['mongodb_connections'] = array(
'default' => array(                             // Connection name/alias
'host' => 'localhost',                       // Omit USER:PASS@ if Mongo isn't configured to use authentication.
'db' => 'YOURDATABASENAME'                   // Database name. Make something up, mongodb will automatically create the database.


# -- Configure Cache
$conf['cache_backends'][] = 'sites/SITENAME/modules/mongodb/mongodb_cache/';
$conf['cache_class_cache'] = 'DrupalMongoDBCache';
$conf['cache_class_cache_bootstrap'] = 'DrupalMongoDBCache';
$conf['cache_default_class'] = 'DrupalMongoDBCache';

# -- Don't touch SQL if in Cache
$conf['page_cache_without_database'] = TRUE;
$conf['page_cache_invoke_hooks'] = FALSE;

# Session Caching
$conf['session_inc'] = 'sites/SITENAME/modules/mongodb/mongodb_session/';
$conf['cache_session'] = 'DrupalMongoDBCache';

# Field Storage
$conf['field_storage_default'] = 'mongodb_field_storage';

# Message Queue
$conf['queue_default_class'] = 'MongoDBQueue';


then Go to your site and enable the MongDB module.

5 Ways To Improve Drupal 7 Performance

Drupal Cache

Using Drupal’s built-in caching is probably the easiest way to improve performance on your site. However, some users that are new to Drupal miss out on this feature because it’s turned off by default. To enable caching for your site, go to the ‘Performance’ settings under the ‘Configuration’ tab.

After enabling caching, Drupal will begin storing database queries in a special table that allows for faster response times. One thing to note about caching is that Drupal is creating copies of the data in your database and these copies can get out of sync with the underlying data.

You can help manage this by setting the ‘Minimum cache lifetime’ and ‘Expiration of cached pages’ options. And of course, the ‘Clear all caches’ button will force Drupal to retrieve the latest data as it rebuilds the cache.

Also on the ‘Performance’ settings page are options to aggregate CSS and JavaScript files. This can help improve your website’s speed as well, but having any of these settings active during development will cause a lot of headaches, so reserve them for use on your production site.


Another great way to improve your site’s performance is the Boost module. One of the big advantages to the Boost module is that it works well in shared hosting environments. A potential drawback is that if you’re not fairly experienced with Drupal, it can be a bit of work to set up.

Boost requires both Poormanscron (included in core with Drupal 7) and clean urls to be working. You’ll also need to have access to your .htaccess and robots.txt files to configure them for the module to work properly. That said, Boost is a great way to speed up your site that is even faster than Drupal’s built-in caching. It works by skipping the Drupal/PHP/SQL process and instead serves HTML or html.gz files.

An important point to note is that Boost only improves performance for anonymous users. If you have a large number of authenticated users, the next solution may work better for you.


Another advanced solution for improving site performance is Memcached, but it’s not for everyone. First of all, it doesn’t work in a shared hosting environment. A second potential issue is that you’ll need to be able to install and configure additional software on the server, so if you don’t have permissions to do this on your host, you may need to seek assistance from a system administrator.

Memcached has three components, the Memcached software, a PHP extension and theDrupal Memcache module that work together to provide in-memory storage of database calls or rendered pages which makes it very fast. The documentation on how to implement Memcached provides a good explanation of how to get up it and running, but if you need further help, the Drupal community is a great place to look.

One interesting point is that a number of Drupal users are reporting success using Memcached and Boost together. If your website has a mix of anonymous and authenticated users, using the two together may be a great solution.

Varnish Cache

Varnish Cache is another solution that can supercharge the performance of your site. Like Memcached, Varnish has additional software to install. This caching HTTP reverse proxy system is quite technical, but if you want a lightning fast solution, it may be worth the investment.

In addition to the Varnish Cache software, you’ll need the Drupal module, Varnish HTTP Accelerator Integration. According to the module page, Varnish will serve pages at a much faster rate than Apache – close to 3,000 page views per second!

For Varnish to be useful on your site, you’ll need either Drupal 7 or PressFlow. Check out theVarnish project page for details.


There are other ways of speeding up your site besides caching. MongoDB is a ‘NoSQL’ type of database that can be used for your Drupal site. Yes, this means there won’t be a MySQL database on the back-end. This database system stores JSON documents instead of the records with which so many of us are familiar. This is how MongoDB avoids those resource hogging JOIN statements.

Another thing that really sets MongoDB apart is that the database is stored in memory, so writes are very fast. MongoDB does do occasional writes back to disk, but such traffic is greatly reduced. One criticism of keeping the database in memory is that some data would be lost in the event of a server crash. With the latest version, however, this issue can be solved with a simple configuration tweak.

NoSQL databases aren’t for everyone (at least not yet). But as proof they can work well for large production sites we can look to Craigslist, Disney and Foursquare among others. Oh, and to get MongoDB up and running, you’ll need the Drupal module.

Wrapping It Up

Perhaps you’ve noticed a pattern here. Additional speed comes at a price. If you don’t own your own server or have dedicated system administrators, you’ll need to invest a bit of time and perhaps money to get a couple of these systems in place. At the very least, your site should have Drupal’s built-in caching system enabled and if you’re not seeing the gains you want from that, Boost is a relatively easy way to improve performance.


the Author :  John Hannah