Remove unnecessary css from drupal website

13 years ago, October 19, 2011

To remove unwanted-style.css from current website do the following in your template.php

function MYTHEME_css_alter(&$css){

         unset($css['sites/all/themes/MYTHEME/css/unwanted-style.css']);
   
}

Detect an iPad or an iPhone in PHP – HTTP_USER_AGENT

13 years ago, October 19, 2011

To detect an iPad or an iPhone in PHP use following function

function is_ipad_or_iphone(){
    if((preg_match("/iPad/",$_SERVER['HTTP_USER_AGENT']) or preg_match("/iPhone/",$_SERVER['HTTP_USER_AGENT'])) and preg_match("/Mobile/",$_SERVER['HTTP_USER_AGENT']))
        return true;
    else
        return false;
}

Drupal – Node reference field returned for interface language rather than node language

13 years ago, October 18, 2011

We have node reference field  "service type" on "service gallery" type content.

Node reference field's select list depends on which language u are in. Eg. If you are in fr language the list will have french service types and if the content u r editing is in english you will be connecting the english service gallery content to a french service type content.
 So you need to be in english language to edit the english content so that the list will show english service types.

Dom PDF – Images dont get displayed

13 years ago, October 14, 2011

I came through this very funny case while i was developing a site which uses DOMPDF to generate PDF from html.

The problem was I was not getting the images in the PDF generated.

I had url_fopen ON on server.

I had tried all relative and absolute paths for the image.

Everything I could imagine.

Drupal 7 – Handling file uploads – allowed file extensions

13 years ago, October 14, 2011

While working with custom forms with file upload fields in drupal, you may sometimes get a error regarding extensions:

The specified file “your file name here” could not be uploaded. Only files with the following extensions are allowed: “jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp”

To allow all extensions, you have to manually set the ‘file_validate_extensions’ validator to an empty array.

© 2024 Anil Maharjan