Listing and Checking Drupal Permissions through Code
Submitted by rajat on Wed, 10/16/2013 - 13:03The following lists all the permissions available in Drupal.
The following lists all the permissions available in Drupal.
During testing phase of the system, there are WSOD for whom no logs are available. Devel is one option, but for knowing just what might be the reason, the following changes in the settings.php file will reveal any error that occured.
Features Update: Update a feature module on your site. This updates the feature module in the site if the components are overriden
drush fu <feature-module-name>
Features Revert: Revert a feature module on your site. Reverts the basic configuration in the module onto the site removing any custom configurations made at the database end.
drush fr <feature-module-name>
To render a Drupal CCK form in a template file, add the following lines in the currently enabled theme. Assuming the enabled theme to be footheme
For a cck form called external_exam, the theme function can be used to provide a template file called external_exam_form.tpl.php under templates directory.
<?php
function footheme_theme() {
return array(
'external_exam_node_form' => array(
'arguments' => array('form' => NULL),
'template' => 'templates/external_exam_form',
'render element' => 'form'
),
);
}
?>
Sometimes we need to render a field when we have a node object containing field values.
field_view_value is a Drupal API that allows us to render any field. Example: Display the Invoice Description Field in a Node Object. The display would take care of any input filter that is applied in the field
<?php
$invoice_description = field_get_items('node', $node, 'field_invoice_description');
print render(field_view_value('node', $node, 'field_invoice_description',$invoice_description[0]));
?>
The other way to display the label and data completely rendered by Drupal.
<?php
Installation and Configuration of Memcached Daemon and PECL Memcache in Ubuntu for Drupal 7
Steps:
1. Install memcached in the server
sudo apt-get install memcached libmemcached-tools
sudo apt-get install php5-dev php-pear make
sudo pecl install memcache
Latest dev Version of Memcache can be installed via.
# If you haven't already installed PECL memcache
pecl install memcache-beta
# If you wish to "upgrade" to a beta release
pecl upgrade memcache-beta
2. Add memcache.ini in PHP conf.d directory
HighCharts is a charting library tool made freely available for non commercial usage. Drupal HighCharts 2.x has no other module dependency except that HighCharts library needs to be downloaded from here. There are a huge variety of options made available in HighCharts API which can be used for manipulation and for additional info.
The example below is a Line Chart uses Drupal HighCharts version 2.x
<?php
/* Render Line Charts using Drupal Highcharts 2.x */
function jicustom_chart_render($chart_arr){
$options = new stdClass();
Sometimes when we visit a link, specially on mobile, there is a situation when we place a link and reaching a page clicking that link leads to a situation where the jQuery library is not loaded into the browser. This could affect conditional fields and other jQuery widgets.
The solution is to add rel="external" to the link.
--
Source
http://stackoverflow.com/questions/10389751/jquery-mobile-page-load-issue
Using views_pre_render hook one can alter the output of a view
<?php
/**
* Implements hook_views_pre_render().
*/
function jicustom_views_pre_render(&$view) {
if($view->name=='stock_report'){
$results = $view->result;
foreach ($results as $key => $result) {
$collection_name = $result->field_collection_item_field_name;
if($collection_name == 'field_transaction_items_outgoing'){
//Modify output
$results[$key]->field_field_trans_item_quantity[0]['rendered']['#markup'] = -($result->field_field_trans_item_quantity[0]['raw']['value']);
}
If you have a CCK Select field and you would want to extract the various options available in that field via custom code, the following lines help you achieve that.