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);
I was trying to style the code snippets highlighted as code as developer in my blog. Did it using some custom css but no positive impression. Recently googling, found an article abt that here . This can be done using syntaxhiglighter . Drop this code right before your </head> tag... and save. And here is the way how you can use it. 1. Using <script> tag with CDATA This will output.... // Commenting this function function custom_one($var) { if($one == $two) { $three = array( 'one', 'two' ); } } 2. Using the <pre> tag. // Commenting this function function custom_one($var) { if($one == $two) { $three = array( 'one', 'two' ); } } This will output.... // Commenting this function function custom_one($var) { if($one == $two) { $three = array( 'one', 'two' ); } }
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
In my scenario, I was using "simplexml_load_file" and getting values in variable. if ($child2->getName() == 'job_title') { print $node_title = $child2; } passing $node_title to node->title using node object and was saving it. It was working well in browser, when i was running script. But created a drush command for it 'drush impvac', which was resulting in docroot$ drush impvac Illegal offset type in isset or empty pathauto.inc:180 [warning] Illegal offset type pathauto.inc:223 [warning] It was because node->title was not getting a plain string from xml, so just added 'check_plain' to dp my stuff. if ($node_title != '') { $node->title = check_plain($node_title); } And all was set.
1- NafeesWeb.ttf (For urdupoint.com etc) Go to http://www.crulp.org/software/localization/Fonts/nafeesWebNaskh.html Download the file with title ‘ Font with MS VOLT project source ‘. Unzip it. 2- asunaskh.ttf (For bbcurdu.com etc) Download from http://www.quran.or.kr/urdu/font/asunaskh.ttf 1- Go to your home directory like /home/[name]. You can use nautilus for this. Click on Places -> Computer and then navigate to your home directory . 2- Now click on ‘ View ‘ in the menu and click ‘ Show hidden files ‘. Or you can use Ctrl+h . 3- Search for folder .fonts . Just create it if it is not there, right click and create a directory with name without quotes ‘ .fonts ‘. 4- Now copy the fonts from the downloaded directory and paste it in .fonts directory. 5- Open terminal and type sudo fc-cache -vf Enter your password if asked 6- Thats it, restart the browsers and check the websites.
Installing Gnome 3 on Ubuntu 12.04 is very easy. Just copy-paste the following lines for the latest release from the Gnome team into a terminal. sudo add-apt-repository ppa:gnome3-team/gnome3 sudo apt-get update sudo apt-get install gnome-shell Now reboot your computer and when you see your login screen you have the following additional options (click on the little Ubuntu icon next to your login name).