You are hereDrupal 7
Drupal 7
MAMP - Drush, can't connect to Database
Using drush on local machine is great. If you have problems where drush can't connect to DB of your drupal, It is probably because of the problem with PHP path so either try something like this
https://github.com/drush-ops/drush#additional-configurations-for-mamp
which advise you to put your PHP path into PATH
export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.3.28/bin:$PATH"
and/or use this export DRUSH_PHP=/Applications/MAMP/bin/php/php5.3.14/bin/php to add variable to make your drush run.
Seems the first one is the one that does the trick here.
p.s.
Some clever functions to check current users, subscribe to organic group etc
I have been building a custom module that has Inviting users to a group feature in it. So there are this helper functions that are very useful.
user_load_by_mail($invitee_email)
will check if there is a user with specific mail, returning false if it is not, returning user object if there is one user with that email
global $user;
$account = clone($user);
og_is_member('node', $current_group->nid, 'user', $account)
will check if there is a user(user object) in a organic group, probably currently logged in user.
Inviting Friends/Sending messages over Facebook, Drupal module/snippet
There is a cool Facebook feature that you can easily implement, inviting or sending messages to Facebook friends with Facebook SDK
Just build a module, a block or whatever you want and put this code in
What is important is to have a FB app and FB APP ID that you have set in some variable, I am using it here with
variable_get('fb_app_id', NULL)
We are using here SEND https://developers.facebook.com/docs/sharing/reference/send-dialog but you can also use other types like invite, request etc https://developers.facebook.com/docs/games/requests/v2.1
Drupal 301 redirect to another domain
This is not so much drupal but sometimes you will move your drupal site to other domain, so then to have your home and all other pages properly redirected add this code to your .htaccess file
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.some-domain.co/$1 [R=301,L]
Advanced modal forms - modal windows with CTools (singe and multistep)
So I client of mine wanted to use popups :) but not just ordinary popups, he wanted to put there, login, registration, node adding, notificiations, user invites for OG, simple menus and even FB login and registration. We also needed to save some user choices before the login/registration and act upon them after the user logs in. So spoiler alert now "if you want to save budget and time" dont't use modal windows or any popups for complex workflows.
Cool login/register screens, without overlays - no regions, just content
As subject tries do describe, to build cool login screens that are popular now and you can find them on sites such as
https://www.icloud.com/ and https://app.buzzsumo.com/login you need to remove all the data from a page and just have content.
Other way you could do this is also with an overlay kind of module, like modal window from CTools or just use modal forms module or some other pop up module. But as I prefer not to use them and have a page that looks like overlay but basically is a content only page we are going to do that now.
Load another node after CTools modal window is submited
Continuing from http://drupaldump.com/ctools-modal-window-return-message-same-modal-window we can also do some more stuff after one modal is submited, we can load another content in it. For example a whole node, we just need to load it and then render it properly. Problem you can encounter is that you will need to change the modal size
$output = array();
$node = node_load(7);
// Content for modal window:
$contents = render(node_view($node, 'full', NULL));
CTools modal window, return message in the same modal window
I wanted to have a confirmation message in modal window, instead of closing the modal and having it on normal page. All that is needed is to check form_state after submit and add this part of code in form function
{
$form = array();
....
if ( $form_state['submitted']){
$output[] = ctools_modal_command_display('Success', '
');
print ajax_render($output);
exit;
}
return $form;
}
and you will have this message in modal window.
p.s.
Views and custom dynamic titles for pages set with fields values or anything else
By default you can't set dynamic titles for views other than using contextual filters and using them to change title, this will sometimes help and sometimes you want to use something else, so custom modules/overrides to the rescue. There is also a page title module but you can use tokens with it and seems it doesnt work now. So use one of this 2 hooks and you will have plenty of info to choose from to set your title. You can use field values, or any other part of view and just put it into title. Here are 2 examples I used and both of them work fine.
Insert something every nth row in Views
Most likely you will want to insert an ADD, probably adsense add every nth row in views. To do that there are 3 methods. One of them is a module a guy made that acts as global filed you add and then you enter what goes in there, problem is that JS code doesnt work there as it is html only field, so some custom formatters should be added. 2 other methods are more straightforward, you just edit the template file and add code there every nth row or you make a view override and on creation of view add a line of code, it can be a node or something else. Here is the list of them with links