When you create a custom form using some custom module, and you want to construct the url after user submit the form... use $form['method'] = 'get'; in the form generation code.
You cant use a putty ppk to ssh to a remote server from you linux machine. In that case you may need to first convert ppk to ssh file. For that first you need to install putty on your machine. $ sudo apt-get install putty Then goto the directory and run the following command to convert ppk to ssh file. $ puttygen key.ppk -O private-openssh -o key.ssh Here, I assume, kep.ppk is you ppk file and key.ssh will be newly created ssh file. After this you can ssh to your remote machine/server using following command. $ ssh user@myserver.com -i key.ssh
I installed phpmyadmin with apache on Linux but I was seeing this at localhost/phpmyadmin Not Found The requested URL /phpmyadmin/ was not found on this server. Apache/2.2.17 (Ubuntu) Server at localhost Port 80 To fix this I had to make changes to apache.conf sudo vim /etc/apache2/apache2.conf and added the following line at the end... Include /etc/phpmyadmin/apache.conf then restart the apache.. sudo service apache2 restart
Before installing NetBeans you need to install JDK software. You can install the JDK software and NetBeans IDE in directories of your choice. Note: This installer does not displace the system version of the Java platform that is supplied by the operating system. You can run the following command to install JDK. sudo apt-get install openjdk-7-jdk Go to the NetBeans download page and download the PHP package. Save the file on the desktop. Now open terminal and run the following command. sudo sh netbeans-7.4-php-linux.sh After unpacking, you will find with the first step of the installation wizard. Go through the installation wizard. After that you will find net beans at Dash home or Applications. Now if you need to configure Netbeans for Drupal, see this .
If you want to compare a field value with it self it was changed or not, you can do it using $node->original in hook_node_presave function custom_node_presave($node) { if ($node->field_name == 1 && $node->original->field_name == 0) { //Do the magic here... } } Here I am comparing if checkbox was newly checked or was already checked. :)
By default checkbox works with 1, 0 values to be checked, unchecked respectivly. $form['custom_checkbox'] = array( '#type' => 'checkbox', '#title' => 'Title', '#default_value' => variable_get('custom_var'), ); you can use #return_value to set a desired value for the checkbox field is it is selected. $form['custom_checkbox'] = array( '#type' => 'checkbox', '#title' => 'Title', '#return_value' => $key, '#default_value' => variable_get('custom_var'), );
I was trying to show status message against an ajax call. Was using rules_link to promote nodes clicking on a link. And wanted to show message if it was done. Here is how I did it.... $commands = array(); $commands[] = ajax_command_prepend('div#ajax-status-messages-wrapper', drupal_set_message(variable_get('limit_po_notification'), 'error')); return array('#type' => 'ajax', '#commands' => $commands);
In Drupal 6, we have been using FormBlock to show the form in the block. But in D7 its pretty simple to do so. After creating a webform, goto form setting at 'node/103/webform/configure' Move down to Advaced Setting and check the "Available as block" option.
I was trying tocome up with a solution for first time login redirection and after that redirection to user profile edit page every time a user logged in. For that I created a role, "First Time Login". Then created a rule using rules module. It will assign role "First Time Login" to a newly created user. Then in the following code, in module "custom_login_redirections" using hook_user_login redirected user to the "Welcome Page" of it has role "First Time Login". // Comment function custom_login_redirections_user_login(&$edit, $account) { if (!isset($_POST['form_id']) || $_POST['form_id'] != 'user_pass_reset') { if(isset($account->roles[30])){ if(in_array($account->roles[30], $account->roles)) { $options = array( 'absolute' => TRUE, 'query' => array('destination' => '#overlay=node/17973') ); $redirec...
It came to me when I was trying to hide field_group on account page. Searching on I found the following solution using hook_form_alter // Comment /** * Implements hook_form_FORM_ID_alter(). */ function MODULE_form_node_form_alter(&$form, &$form_state) { global $user; // The 'internal' field groups should only be accessible for regional administrators. if (!in_array('regional administrator', $user->roles)) { foreach (array('group_action_internal', 'group_company_internal', 'group_topic_internal') as $fieldgroup) { if (isset($form['#fieldgroups'][$fieldgroup]) && isset($form['#group_children'])) { // Hide the field group itself. $form['#fieldgroups'][$fieldgroup]->format_type = 'hidden'; // Hide the elements inside the field group. foreach ($form['#group_children'] as $field => $group) { if ($group == $fieldgroup) { ...
Downloading modules: $ drush dl module_name It will automaticly download extracted module to modules folder in your project. Enabling modules: $ drush en module_name Disabling modules: $ drush pm-disable module_name Unistalling modules: $ drush pm-uninstall module_name Clear Cache: You can use the following command to clear all cache of your site. $ drush cc all List modules: $ drush pm-list --type=module And if you want to list only non core modules, you can use $ drush pm-list --type=module --no-core --pipe SQL dump: $ drush sql-dump > filename.sql It will automatically take the dump of the database of the project in which you are. status (st) Check the Status: Provides a birds-eye view of the current Drupal installation, if any. $ drush status Check the Recent Watchdog: To list the recent watch dog status, us the following. $ drush ws ws referes to Watchdog show. Database connection detail: Provides a bi...
Here we will see how to install Drupal on a LAMP environment. We can do it using two ways, one is downloading it manulay and other is install it using DRUSH.(We will see how to install drush in next sections.) Downloading and Extracting Drupal You can download latest Drupal by going to https://drupal.org/project/drupal are by using any utility. Here we will be using wget in shell. wget http://ftp.drupal.org/files/projects/drupal-x.x.tar.gz You can replace x.x with the version you want to download. For example.. wget http://ftp.drupal.org/files/projects/drupal-7.22.tar.gz Now time to exteact the file you just downloaded. tar -zxvf drupal-7.22.tar.gz After extracting you can move files in drupal-7.22.tar.gz directory one level "up" into the web server's document root or your public HTML directory. mv drupal-7.22/* /var/www/local.mysite.com/docroot NOTE: In your web server's configuration file the base URL for your Drupal installation wil...
If you want to set a menu item of the main menu as active (class="active"). Here is how you can do this.. function mymodule_init() { $link=menu_link_load(2570); $link["options"]["attributes"]["class"]="active"; menu_link_save($link); } 2570 is mlid of that perticuler menu item. You can check it by editing that perticuler menu item "admin/build/menu/item/2570/edit" Now, I just want to set it active on some specific pages... like "mypage01", "mypage02" etc function mymodule_init() { if((arg(0) == 'mypage01') || (arg(0) == 'mypage02')) { $link=menu_link_load(2570); $link["options"]["attributes"]["class"]="active"; menu_link_save($link); $menu_active = 1; } else { if($menu_active == 1) { $link=menu_link_load(2570); $link["options"]["attributes"]["class"]=""; m...
Download the shell script from here Once you have php5_4_downgrade_5.3.sh file you need to change the permissions using the following command su root chmod u+x ./php5_4_downgrade_5.3.sh Now you can run the script using the following command sudo sh php5_4_downgrade_5.3.sh Follow the on instructions
Drush is raealy handy to do the Drupal stuff ver quick and easy. If you haven't already installed Drush check http://drupal.org/project/drush. Installing Drupal 7 with DRUSH is awsome, with just two simple commands, setting up MYSQL user and DB, note down the passwoprd, then run the following comman. Make sure to replace the user and passwords names for your local setup: drush dl drupal-7.x drush site-install standard --account-name=admin --account-pass=admin --db-url=mysql://MySQLUser:Password@localhost/MySQLDatabase ...and you're done. *Note: The Drupal username and password seemed to always end up as admin/admin. So, just using those and then changing them after you login to your new site.
Drupal by default creates a blog view for evry use at sitename.com/blogs/user-name. To override this view with your custom one, create a page view of content type Blog Entry, with path as "blogs/%". Add "Content: Author" in Relationship. As you can see in below screen shot. Now you need to filter it by the author of content. In contextual filter use "(Author) user: Uid" with selection of "Specify Validation Criteria", Choose user as "Validator". See attached screen shot for this. And there you go. Now what ever url you set in path auto, it will get that automatically.
Sometimes, whether in testing or other situations, you need to reset a password (often the admin password) for a Drupal site. The shortest answer is that two wonderful options are built into drush! # Get an admin login link drush uli # Set the password for any user drush upwd admin --password="newpassword"
Copy the hash.. $S$C6x2r.aW5Nkg7st6/u.IKWjTerHXscjPtu4spwhCVZlP89UKcbb/ (that’s the hash for newPassword ). Navigate to your phpMyAdmin (likely in your control panel online somewhere). Then browse the User table for the Root user, look like his. Take the copied hashed text and paste it into the pass field of the Root user and hit “Go”. See this If you want to reset Drupal pasword using Drush .
Drupal by default donot provide user's author detail in views or any where in data base. Once I went through this kind of requirnment to list users with detail, who created those users. A simple way in D7 is to add text field in "user_register_form". That field will be hidden and will get current user's detail in it. We will do this using a module with hook_form_alter. Say you added a text field in user registration form with name "field_authortxt" Add the following code in .module file function custom_user_author_form_alter(&$form, &$form_state, $form_id) { if(( $form_id == "user_register_form") || ( $form_id == "user_profile_form")){ $lang = $form['field_authortxt']['#language']; global $user; $form['field_authortxt'][$lang][0]['value']['#default_value'] = $user->name; $form['#after_build'][] = '_tansnippet_after_build'; } } Now we need to hid...
This may have several reasons to appear.. In my case I found it as I was missing "$form['form_token']" in my template file of user register form. As a from need to have $form['form_build_id'] $form['form_id'] $form['form_token'] to proceed for proper submissions. Note: Above values are hidden values. Drupal - Custom Login Redirect to current page