Drupal 7 Apache Solr Configuration

3 Apr


Thanks to lullabot for this nice post which produces exact output that it says. In my case i had to make few other changes in my CENTOS cloud server.


1.  Instead of recommended version of drupal apachesolr module; I took the dev version for solr configuration. 

2. You wont be able to access http://localhost:8983  

The reason behind this is firewall if you have iptables enabled . Open /etc/sysconfig/iptables and add following line:

# Tomcat Port
-A INPUT -p tcp --dport 8983 -j ACCEPT

Then restart iptables #/etc/init.d/iptables restart .  Now you can access tomcat server.

3. That article didnt speak much about security.  VISIT I found this post to secure SOLR admin panel. There is truncated tags in that XML . See the github gist  comment to fix this. 

4.  In drupal admin level use http://username:password@localhost:8983/solr/drupal 



Finally  configure the basic settings for solr inside drupal admin. I used drush solr-index  to index my contents. Thats it , Enjoy SOLR !



https://drupal.org/node/1333076   This post discusses above security and configuration related to admin.


Admin_views Module with multiple user

2 Apr

Module URL:  admin_views

We use this module to provide nice filtering features for our client. In few cases we share create different roles based on client request. Such as, This particular user can only edit his contents or specific content types. A good feature of admin_views is that it does considers user permission and renders admin links based on that. But one problem is that if the site has huge list of contents; its hard to find a single content from a list of thousand items.

To make this user intuitive, we want to show only user contents in Content Management but for specific roles we will show them all. To do that follow these steps:

1. Go to Views and open edit form for “Administration: Nodes” .  Admin_views module utilises this module.

2. Add a contextual Filter Author: uid  . Click on “Provide Default Value” and choose PHP code. Note: If you dont see php code in here then enable PHP filter module from Modules.

3. Now put following snippet in the “PHP contextual filter code” :

global $user;

if( in_array( 'administrator', $user->roles) )
  return 'all';
  return $user->uid;

4. Finally Save the views .

Thats it . Now only administrator can view entire list but for other roles only authored contents will be visible to logged in user.

VIM really enhanced

12 Feb

I am a regular SublimeText user. Vim has always been my favourite editor of choice when i need to do small tweaks and etc. I kept an eye on recent vim plugins and posts made by numerous vim lovers. The ultimate goal was to make vim more easier and more friendly. Here are my tips and tricks that i used to make vim close to Sublime :

  1. Vundle : I have used pathogen to manage my plugins. Vundle takes plugins management to a whole new level. Think of it as Sublime Package manager. Just put the github repo name and run “BundleInstall” . Before you do this make sure your vim supports ruby and install Vundle in your system. To check if your system has ruby support run :
    $vim –version | grep ruby
    If nothing comes up then make sure you update your vim with ruby support.
  2. Vim-airline: Makes vim status and tab bar intuitive. Some cool themes for eyecandy.
  3. Vim-unimpaired : Buffer is a cool way to edit multiple files in vim. But switching them can be hectic. [b  a nice key map to switch between buffers.
  4. ctrlP : NerdTree provides a cool file explorer but nothing can beat the fuzzy search to load specific file. Those who have used it never looked back. This plugin provides the exact same feature in vim.
  5. vim-multiple-cursor : First saw this feature in Notepad++ . A very handy way to refactor code lines. Better than typical Search/Replace.


Finally there are tons of dotfiles around . Dont copy and paste those into your vimrc. I used to do that which does not helps you to learn. Instead pick one dotfile then try to understand each lines. Only move those that you think will help you eventually.

My vimrc file. :)


11 Feb

Lots of complains adopting git, is not to have a server that support ssh let alone git. A nice post by jefferey way in nettuts suggests deployhq. Thats a nice service with nice GUI . But i was looking for a free solution and found one under a comment in that post.


This not only provides FTP protocol also support SFTP. Here are the steps that i took in my mac os environment.

  • I used brew to install git-ftp:
    $brew install git-ftp
  • This relies on libcurl so next thing i had to install curl with ssh support :
    $brew install curl –with-ssh
  • Brew does not overrides default curl library that comes with osx,  so i had to replace that using
    $sudo rm /usr/bin/curl
    $sudo ln -s /usr/local/Cellar/curl/7.35.0/bin/curl /usr/bin/curl
  • Now I cd into my repository and run :
    $git ftp init -u <username> -p – sftp://<host_url>/<path>
  • It syncs my current HEAD branch into the server and keeps track of last commit. So after making few other commits, i am ready to push latest changes to server. By running:
    $git ftp push -u <username> -p – sftp://<host_url>/<path>

I hope from now on you will use GIT for server deployment.

NOTE: git-ftp stores commit log in a file .git-ftp.log file. If any mishaps happens or you want to re-sync everything. Remove that file and you are good to go.

Sublimetext Package: SideBarEnhancements

20 Apr

This is one of those packages that should be in core. This enhances the default simple sidebar with additional operations.  You can install this via Package Control or from their git repository.


Sublimetext Plugins: Gitgutter

19 Apr

I am going to write series of posts showing my favorite plugins for Sublimetext editor. Sublimetext is one of the coolest editor around. Today we are going to learn about gitgutter . If you are using git for versioning then you have to have this plugin.  It shows a realtime git diff in your editor.


I was looking for  a plugin like this when i switched from netbeans. Netbeans has this cool plugin named nbgit which i loved most.

I hope this plugin grows more powerful.  BTW you can install this via package control too. More details

CodeIgniter Composer Twig Doctrine

22 Aug

Its not always the power of a framework, its (human) resource that acts as key factor for final selection. On such cases the best option is to add the best things from the new framework and incorporate with the selected one. I really liked symfony2 components and wanted to have that in my CodeIgniter pack also wanted to leverage the power of composer.

After digging and headbanging for few hours; its a SUCCESS. So now my pack relies on composer’s autoload, uses twig template engine and uses doctrine.

Here are my code : ( 99% are of others I just patched those for my need )

Thanks guys for your hard work which saved tons of hours for me. Here are the references:

  1. http://philsturgeon.co.uk/blog/2012/05/composer-with-codeigniter
  2. https://github.com/dilantha/codeigniter-twig
  3. http://www.joelverhagen.com/blog/2011/05/setting-up-codeigniter-2-with-doctrine-2-the-right-way/

I will try to update this code based on issues i face. Do let me know if anything  is missing or needs any modification.


Get every new post delivered to your Inbox.