CMS Drupal PHP


Drupal - To display error and debug the code



 To display error and debug the code add below line in any php/module file at starting of the soudrce code. It provide detail error track to analyze the code.

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

Some time due to compilation error complete screen would go blank below
debug message wont help and developer will have no clue to solve it  -> http://drupal-cms-india.blogspot.in/2012/06/drupal-white-page-issue-compilation.html


 Drupal - White Page issue - Compilation issue




Some time due to compilation error complete screen would go blank even by giving the looger message display_errors. There are number of reason for it one of the reason while doing a custom module is compilation error. So compile the module/php files before executing it.

In Unix:
$ php <filename>

 In Windows using wamp:
C:\sw\wamp\bin\php\php5.3.9>php C:\sw\wamp\www\OnlineEdit-June02\sites\all\
modules\custom_mp_seller_form\custom_mp_seller_form.module

More solution on white space http://drupal.org/node/158043


 Drupal - Add Custom Tab under My Account




In Drupal Tab is getting handled by Menu Local Task. So under menu function of our custom module we need to add type as MENU_LOCAL_TASK.


function custom_mp_seller_form_menu() {


  $items = array();


  $items['user/%user/SellerAdditionInformation'] = array(
    'title' => 'Seller Addition Information',
    'page callback' => 'custom_mp_seller_form_addAdditionalSellerInfo',
    'access arguments' => array('Use custom_mp_seller_form'),
    'type' => MENU_LOCAL_TASK
  );

  return $items;
}





Ubercart popular product not displaying




Ubercart popular product not displaying due to view not having the required data


Issue is my hosting companynot providing permission for view-table access. So finally i have created custom module to display top/popular products.

Below is my custom module to display the popular product in block

<?php


/**
 * Implementation of hook_perm().
 */
function custom_uc_top_products_perm() {
  return array('custom_uc_top_products');
}

/**
* Implementation of hook_block().
*/

function custom_uc_top_products_block($op='list', $delta='my', $edit = array()) {
  // set up the block
  $block = array();

  switch ($op) {
    case "list":
        // Generate listing of blocks from this module, for the admin/block page
        $block[0]["info"] = t("On This Date");
        break;

    case "view":
        // Generate content for blocks from this module
        $block_content = "";
          
        $query = "SELECT * FROM uc_products";
        
        $query = "SELECT op.nid AS nid, SUM(op.qty) AS sum_qty, product.sell_price
FROM uc_order_products op, uc_products product where op.nid = product.nid GROUP BY op.nid ORDER BY sum_qty desc limit 1";
       
        $result=db_query($query);
// $block_content = mysql_result($result, 0);


 while ($product = db_fetch_object($result)) {
     $product = node_load($product ->nid);

    $field = variable_get('uc_image_product', '');
  
   $imagelink = l(theme('imagecache', 'product_list', $product->{$field}[0]['filepath'], $product->title, $product->title), "node/$product->nid", array('html' => TRUE));
  
   $block_content =  $block_content .$imagelink."</br>";
   $block_content = $block_content."Only: ".uc_price($product->sell_price);
 } 
      
        //Setup the block      
        $block["subject"] = t("Top 10 Products");
      
        //Check that content isn't empty
        if ($block_content == "") {
            $block_content = t("Sorry No Content");          
        }
              
        $block["content"] = $block_content;
        break;


    case "save":
       break;

    case "configure":
       break;
  }         

  return $block;
}  // end onthisdate_block



Virtualmin PHP update 5.2





While using virtualmin as control[anel we can upgrade php version to 5.2  by using below command

1. rpm -ivh http://software.virtualmin.com/bleed/centos/5/i386/virtualmin-bleed-release-1.0-1.rhel.noarch.rpm

2. php update install


http://www.virtualmin.com/node/15405



Installing APC in Cent OS



Step 1. First install yum install php-devel php-pear httpd-devel

yum install yum install php-devel php-pear httpd-devel





Step 2. Then install APC



 pecl install apc




Step 3: add the following at the beginning of /usr/share/pear/pearcmd.php



@ini_set('memory_limit', '16M');



Step 4.  echo extension="apc.so" >> /etc/php.ini

To find the exact location of php.ini you can use "whereis php.ini" command :)



Step  4.


Configure/Restart

Now configure PHP to use the new extension. Create the file/etc/php.d/apc.iniand in that file put:

extension=apc.so

Now restart apache

/etc/init.d/httpd start



Source:http://securewebs.com/apc-php-cache/


1 comment:

  1. I think you should post now. Its being a long time to read from your latest posts here.Please add more valuable post for us. Deciding on a Content Management System is extremely vital I am a big fan of Drupal. Because Considering the largest companies like Cisco use Durpal, it is an easy decision For our hosting I chose GetPantheon including the capability to go live with 1 click which platform have you tried?

    ReplyDelete