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:
  */sites/all/themes/*/sass
  /Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/frameworks/blueprint/stylesheets

  /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/*';


to 

@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
>  SAVE SETTINGS
 > admin > configuration > 'Your Server' > edit

2. 
> 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 {}
 ->fields(array(
              'read_only' => 1,
          ))
          ->condition('read_only', '0', '=')
          ->execute();
    }
  }

}


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)) {
    unset($order_statuses['cart']);
    unset($order_statuses['checkout_checkout']);
    unset($order_statuses['checkout_shipping']);
    unset($order_statuses['checkout_review']);
    unset($order_statuses['checkout_payment']);
    unset($order_statuses['checkout_complete']);
  }

}

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]