New Age sliders and carousel (Responsive)
After using views slideshow and jCarousel (and not so happy the way they work, mostly in theming department) there are new players in town and they are even responsive. Also easy to theme and easy to setup.
https://drupal.org/project/flexslider
https://drupal.org/project/owl-carousel
Flexslider is great for slideshows, they can even pull carousels but for great responsive carousels use the owl carousel. Just a note, owl for drupal is pretty beta, so you will need to use dev version and also use jquery update 1.8 version, otherwise you may end up with empty space in place of carousel.
Omega 4 and Compiling Sass on Windows (how to install and make it work)
I know Sass and Less are major improvements in Css coding, but setting all this up is a drag. I was using Omega 4 and to style it we need to use Sass coding. There are enough resources out there, but they are often limited to some special use case scenario and as there are many components to make it work you will have problems when trying to set it up. So after a day of work I finally pulled it off and made this Sass thing work and auto compile to Css.
Great RFP (Request for Proposal) for new Drupal Job board site
https://association.drupal.org/node/18998 I just really like that RFP (Request for Proposal) was done online and you can access all the documents on that link and see how professional RFP should be made and what project documentation should every project have (as many don't have).
No file found - get the file object in file upload validate function
I had a form without this "name" parametar, and without that parametar there is just no file object in validate function for file upload
'#name' => 'files[advert]',
'#type' => 'file',
'#title' => '
'.t('Add New Image').'
',
'#description' => t('Upload a file, allowed extensions: jpg, jpeg, png, gif'),
);
and then you can get it in validate function like below with 'advert'
{
Tableselect Form API - How to delete/edit selected rows from tableselect
To delete/edit selected rows from tableselect and have something to work in in form_state you should add keys to your array in your form like:
foreach($fullList as $line)
{
$rows[$line->category] = array(
'tid' => $line->category,
);
}
This way you will be able to easily retrieve values on your submit/delete handler on $form_state
$delete = db_delete('htb_if_categories')
->condition('category', $rows, '=')
Setting Sessions and Cookies
Setting a session in Drupal is easy, everything is set from the Drupal boostrap, all you need to do is to set it and get it. Like
$_SESSION['zip'] = $form_state['values']['zip_code'];
and latter you just get value on some page like
$view_filters['field_zip_range']['value'] = $_SESSION['zip'];
and it works. Just be careful of caching and varnish and similar things as they sometimes do not cooparate.
Session is set on server side.
For client side, you use cookies and set it like this
user_cookie_save(array('key'=>'value'));
print $_COOKIE['Drupal_visitor_key'];
View 3, alter filters programmatically
if ($view->name === 'pricing') {
$view_filters = $view->display_handler->get_option('filters');
$view_filters['field_zip_range']['value'] = $_SESSION['zip_code'];
$overrides = array();
$overrides['filters'] = $view_filters;
foreach ($overrides as $option => $definition) {
$view->display_handler->override_option($option, $definition);
}
}
}
Views 3 query altering with hook_views_query_alter
You can alter views, alter queries and much more. Problem with documentation online is that is lacking some crucial information.
First, you should put your alter function in separate file, your_module.views.inc
as it is said here
https://api.drupal.org/api/views/views.api.php/function/hook_views_query...
What you also need to do is implement hook_views_api, it is said above that you don't have to but with lates views 3.0 it won't work if you don't do it, so you add this little line
return array('api' => 3.0);
}
Modal form, CTools automodal and redirect
Currently I am using a https://drupal.org/project/ctools_automodal for my modal forms, that use CTools and its form dialogs for nice overlay forms (well not so nice, they look ugly as hell, but you can theme things :) ).
So there are some good tutorials how to setup modal forms and make you forms in overlay
http://deeson-online.co.uk/labs/insert-form-pop-modal-ctools-and-drupal-7
http://drupion.com/blog/10-steps-creating-ctools-modal-window-drupal-7
WSOD or white screen of death and error reporting
Sometimes you will have a WSOD and nothing to show for. One simple solution to get what is a problem is to insert the following lines into the Drupal's index.php, that should set PHP to report all errors.
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
?>
and you will probably see that some module is making a problem, so you can fix it or disable it.