Tuesday, 27 January 2015

Drupal Theming - Bootstrap Import errors - import not found or unreadable: bootstrap.

here was the error

error sass/bootstrap/test/dummy_sass_only/import_all.sass (Line 1: File to import not found or unreadable: bootstrap.
Load paths:

  /Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets   Compass::SpriteImporter)

The fix was to change this line in /sites/all/themes/my_theme/sass/custom.scss

@import 'bootstrap/assets/stylesheets/*';


@import 'bootstrap/assets/stylesheets/bootstrap’;

Adding Excerpts to Solr Search Results - Including attachments

First off I’m going to address the question ‘ How to Add Excerpts to the Solr Search API ‘ .

This is worthy of note as the obvious way is to do it through the Search API UI; when in fact this method needs to be disabled and instead edited on the Solr Server Settings ‘ Still within Search API setting ‘ 

Step-by-step guide

  1. Check the following is disabled.
> admin > configuration > filters > under ‘Processors
> check that ‘Highlighting’ is unticked
 > admin > configuration > 'Your Server' > edit

> under 'Advanced' > tick 'Return an excerpt for all results.'
> 'Save settings’

3. Then in your view for the search you have add ‘Search: Excerpt’  Field. 

Adding an excerpt from an Attachment 

There’s is a bug with Search API and Excerpts; currently there is a patch which isn’t on the development release. Go to this page to get this 

Friday, 23 January 2015

Drupal 7 - how to make a panelled Search page.

Instructions on how to make a panelled Search page .  Like this

Step-by-step guide

Add the steps involved:
  1. in > admin > Structure > Blocks
  2. Search for your facets and select the block you want them to go in . ie 'Sidebar First'

  3. SAVE

  4. open your View > Page .

  5. under FORMAT change Show to 'Panel Fields'

  6. In Settings choose your Panel Layout from the list. ie 'AT One Column' should display the above block example.

7. And then still in the VIEW - making sure you are in the 'Page' display; otherwise you won't see this option. Under 'Advanced' - you should now see under 'Exposed Form' the text 'Exposed form in block:' - Change this to Yes.
8. Once you've added this to the view you'll now be able to go back to > structure > blocks.
And see the exposed form here to move to the block you wish.

Thursday, 22 January 2015

Drupal 7: Programatically Make Solr 'Read Only' on none live environments . Acquia

The following code is no longer needed once 'Adding Multiple Search Cores' is set up.  However it's worth documentation as the Multi search core facility may not be available for all.

Here's a piece of code I wrote to make a search 'Read Only' - also in here is how you can set an index up - and leave that one live for testing. 

if ($_ENV['AH_SITE_ENVIRONMENT'] == 'prod' ) {
  // check for live environment
else {

  $result = db_query('SELECT name, server, read_only, machine_name
 FROM {search_api_index}
  $rowcount = $result->rowCount();
  //print "Query $rowcount 
 foreach ($result as $record) {
  // print_r($record);
 $read_only_value = $record->read_only;
    // print "Read only value = $read_only_value - v1
 // machine_name check here has only been added for pre testing before going live with this search
 // delete when this search is added for real.
 if ($read_only_value == '0' && machine_name != 'candidate_cv_search'){
      $updated = db_update('search_api_index') // Table name no longer needs {}
              'read_only' => 1,
          ->condition('read_only', '0', '=')


Wednesday, 21 January 2015

Drupal 7 Commerce : How to send Emails to Users of a Certain Role

  1.  'store settings' > checkout settings > click on the 'checkout rules’ tab  >
  2.  Click on ‘Add a Checkout Rule’ 
  3. Fill out a name
  4. Add Event - Completing the checkout process
  5. Add Actions > Under system > Send HTML mail to all users of a role’ 
  6. SAVE

Tuesday, 20 January 2015

Drupal 7 commerce can i remove order statuses

The Situation:

I have a role of 'Sales Manager' - they have access to manage the orders.

On the dropdown for Order statuses I can see the following . 

What I'd like to do though is limit this to - Pending, Process and Completed.

To fix this the following code works a treat.

 * Implements hook_commerce_order_status_info_alter

function my_commerce_patch_commerce_order_status_info_alter(&$order_statuses){

 global $user;

  if (in_array('sales manager', $user->roles)) {


Drupal 7 commerce cart not showing titles - after kickstart installation.

I found this one a little difficult to find.  So here’s where it’s at. 

Look for the view Shopping cart form .  and click on Edit.

> on the right hand side click on 'Add' next to 'Relationships'

> Add 'Line items referenced by commerce_line_items) Commerce Line item: Product

> Then in Fields add 'Commerce Line item: Product'

> click on 'rearrange' next to fields.  drag above 'Global text'

In that View what you need to edit if the field Custom text’  

> and then rearrange the tokens in the Text that you wish.   I added [line_item_title]

Drupal 7 : Saving Views prints machine code

This is something thats happened a couple of times to me on different projects; so I though I'd document it.

On saving a view I was getting a page of output that started with  

The issue here is with JQuery.  So take a look at what JQuery is being used or install the 'JQuery Update' module. 

Drupal 7 adding User to Menu Link.

Adding %user to Menu Link  - use tokens -  try the ‘Menu Token ‘  module. 

Here's how I solved this one. 

Installed the Module Menu Token  .  I had to use the Development Release here as the Recommended release did not work for me.  It also needs the Universal Unique Id module .

1. Add the module 'Menu Token'
2. Go to the Modules 'configuration'
3. Add the entities that you'll be needing the tokens from ..
4. Add your path link following the modules instruction - ie user/[current-user:uid]/profile
5. tick 'use tokens'
6. Select how you want this relationship to work from the dropdowns. ie 'Method for Users' = 'User from context'

For menus go to add links and then follow the instructions from stage 4. 

Monday, 19 January 2015

Drupal 7 Commerce : Drupal Page Manager Views not showing in Pane selection

Drupal Page Manager Views not showing in Pane selection

Enable the module ' View Content Pane '

Drupal 7 Commerce : All products to be listed on one page.

Here's the look we're trying to achieve. 

Step-by-step guide

  1. Install this Module - 'Commerce Add to Cart Extras ' - https://www.drupal.org/project/commerce_add_to_cart_extras
  2. Add a View
  3. Type = 'Commerce Product'
  4. I've used a Megarow Table as the Format in my example. 
  5. in Fields I've Added 'Commerce Product: Product ID' , 'Field: Title' 

Drupal 7 Commerce : Inventory Stock Ordering Page.

For Inventory Administration we would like an easy to use page where stock can easily be update. 

Step-by-step guide

  1. Install 'Commerce Stock' module .  - https://www.drupal.org/project/commerce_stock
  2. install ' Editable Views ' module .  https://www.drupal.org/project/editableviews
  3. Add a new view
  4. Select 'commerce product' 
  5. Display Format should be set to 'editable table'
  6. Add the fields you wish.  using (editable) version for where you want to be able to edit it. 

Drupal 7 Commerce : How to Return a list of a Users Orders in Views.

The aim here is to reduce the checkout process as much as we can; as in the website we are currently  creating we do not need  user address, Shipping and payment.

Step-by-step guide

  1.  Login to 'Store settings'
  2. Drag and drop 'Review' and 'Shipping Service' under 'Disabled'
  3. See images for further setup instructions
  4. You can then use CSS to get rid of things that don't need to be seen

Drupal 7 - Page Manger - Panels - No gear button - Can't add Views

In the eventually you can't see the 'Gear button' on Panels / Panelizer .   Like this

This is a JQuery issue.

You should either add the module 'JQuery Update'  ; if you have already installed this module then you may well need to check the settings.  Try changing the default JQuery version or the 'Alternate jQuery version for administrative pages'  .  Save and Clear Cache.