The function that displays the url of the current page
request_uri();
To use it in if statement; emplor strpos php function
$url = request_uri();
if (strpos($url, “contact”)) { print “this the contact page”; }
I have faced this horrible issue of transferring database from either my localhost to the server or transferring from one hosting server to another.
The even for small drupal sites the database gets so huge that transferring is not possible at times. There is a timeout error and when I tried to upload per table, life became unbearable.
So i came with this solution hoping to help whoever is stuck with dilemma.
The solution is just to import first the database structure and then the database data excluding all the cache tables and watchdog table. Probably it is an obvious solution but I literally sweated to get to it.
The opacity feature of css does not work on internet explorer IE, to overcome that use filter option.
Eg
.change_opacity {
opacity: 0.5;
filter: alpha(opacity = 50);
}
Note: The value of filter is different from opacity
Click here to view the source
When using the error reporting feature of drupal I faced my theme getting screwed up, the regions and block of left side went missing. After searching drupal posts etc I found the following solution for drupal 6:
Add the following function in your theme’s template.php file:
Click here to find a solution for drupal 5
<?php
/**
* Override or insert PHPTemplate variables into the templates.
*/
function phptemplate_preprocess_page(&$vars) {
// handy helper for themes, not related to 404 issue
$vars['base_path'] = base_path();
// Only does the check if required
if(!$vars['show_blocks']) {
global $theme;
$regions = system_region_list($theme);
foreach (array_keys($regions) as $region) {
// Only set left and right regions
// Drupal core sets the other blocks already
// IMHO this shows a real lack of design considerations for leaving these out!
if ($region == 'left' || $region == 'right') {
$blocks = theme('blocks', $region);
if(isset($variables[$region])) {
$vars[$region] .= $blocks;
}
else {
$vars[$region] = $blocks;
}
}
}
}
}
?>I wanted to the shopping cart to look more elegant so I used the sliding effect of jquery, css opacity transparency and reduce the summary to enable a one line heading “shopping cart” and when it is clicked a curtain or sliding effect is enabled showing a see through cart.
Sliding Effect:
Transperancy
Open style.css of your theme and add the following:
#cart-block-contents {
background:none repeat scroll 0 0 #FFFFFF;
border:3px solid black;
margin-top:-14px;
opacity:0.9;
position:absolute;
z-index:100000;
}
Reduce the cart summary
Open template.php in your theme (if the file is missing create it) and add the following function:
function myuniform_uc_cart_block_content($help_text, $items, $item_count, $item_text, $total, $summary_links) {
$output = ”;
// Add the help text if enabled.
if ($help_text) {
$output .= ‘<span>’. $help_text .’</span>’;
}
// Add a wrapper div for use when collapsing the block.
$output .= ‘<div id=”cart-block-contents”>’;
// Add a table of items in the cart or the empty message.
$output .= theme(’uc_cart_block_items’, $items);
$output .= theme(’uc_cart_block_summary’, $item_count, $item_text, $total, $summary_links);
$output .= ‘</div>’;
// Add the summary section beneath the items table.
return $output;
}
Note: myuniform is the name of my theme, so write just replace it with your theme name.
The option_image module which changes image when an attribute option is changed does not work on my theme but is working with garland.
The solution for that lies in the node.tpl file .. copy paste the node.tpl from garland to your theme and start customizing it. My error was because i had skipped id=”node-<?php print $node->nid; ?>” and i had removed the class=”content clear-block” from <div> printing the $content.
If you are using the grid layout override this function theme_uc_catalog_product_grid($products) and where it says $imagelink=”; give the path of your image.
Now how it goes is that you open the template.php (if it is not there create it) in your theme folder and enter the above function with your changes. Click here to view the list of other theamable ubercart functions.
Eg: Note: myuniform is the name of my theme
<?php
//theme the product image for the catalog basically to add a default image when product image not present
function myuniform_uc_catalog_product_grid($products) {
$product_table = ‘<div><table>’;
$count = 0;
$context = array(
‘revision’ => ‘themed’,
‘type’ => ‘product’,
);
foreach ($products as $nid) {
$product = node_load($nid);
$context['subject'] = array(’node’ => $product);
if ($count == 0) {
$product_table .= “<tr>”;
}
elseif ($count % variable_get(’uc_catalog_grid_display_width’, 3) == 0) {
$product_table .= “</tr><tr>”;
}
$titlelink = l($product->title, “node/$nid”, array(’html’ => TRUE));
if (module_exists(’imagecache’) && ($field = variable_get(’uc_image_’. $product->type, ”)) && isset($product->$field) && file_exists($product->{$field}[0]['filepath'])) {
$imagelink = l(theme(’imagecache’, ‘product_list’, $product->{$field}[0]['filepath'], $product->title, $product->title), “node/$nid”, array(’html’ => TRUE));
}
else {
$imagelink = ‘<img src=”/uniform/sites/default/files/default-small-uniform.jpg”>’;
}
$product_table .= ‘<td>’;
if (variable_get(’uc_catalog_grid_display_title’, TRUE)) {
$product_table .= ‘<span>’. $titlelink .’</span>’;
}
if (variable_get(’uc_catalog_grid_display_model’, TRUE)) {
$product_table .= ‘<span>’. $product->model .’</span>’;
}
$product_table .= ‘<span>’. $imagelink .’</span>’;
if (variable_get(’uc_catalog_grid_display_sell_price’, TRUE)) {
$product_table .= ‘<span>’. uc_price($product->sell_price, $context) .’</span>’;
}
if (module_exists(’uc_cart’) && variable_get(’uc_catalog_grid_display_add_to_cart’, TRUE)) {
if (variable_get(’uc_catalog_grid_display_attributes’, TRUE)) {
$product_table .= theme(’uc_product_add_to_cart’, $product);
}
else {
$product_table .= drupal_get_form(’uc_catalog_buy_it_now_form_’. $product->nid, $product);
}
}
$product_table .= ‘</td>’;
$count++;
}
$product_table .= “</tr></table></div>”;
return $product_table;
}
?>
I finally decided to use apache webs server on my local PC instead of IIS (the usual Microsoft gala bala) .. anyways so I got apache XAMPP installed configured and all … but I realized I did not know how to add a new site, i was googling everywhere but could not find a simple solution … may be keywords i was using was wrong or something .. anyways if anyone is looking for the same here’s is the solution
Add your website folder at
c:/xampp/htdocs
and that does it !
The transaction was all smooth but when i returned after the payment i got a page not found error plus the transaction and order details were not registering in the system.
The solution was very simple just uninstall and install the uc_migs module and it worked like a charm ![]()
Most online payment gateways have issues running in the middle east like paypal etc. So I found the best solution for online payment in the middle east and other countries as well to be MIGS.
When I was building an ecommerce application I used drupal with ubercart and uc_migs module for the online payment where was the payment gateway.
Different banks have different requirements but mostly MIGS is useful if the store has a large scale sale target as in my case Emirates NBD bank in Dubai has provided us with MIGS payment gateway through a company called Network Solutions. The bank needed a deposit of around 10000 USD along with an annual fee plus per transaction charges. So you can imagine… For small stores you can always use paypal, google checkout but they again have the limitations of not working in AED currency and mostly require a bank in the US with tax issues and what not.
Note:
MIGS – (MasterCard Internet Gateway Service) for what they call the “3rd party” integration method, or the Virtual Payment Client (VPC) which is the interface that processes the payment on their secure server, a bit like 2checkout. This service is used by more than 400 banks arround the World.
I had a very hard time finding this module & fixing it because people call it by the name of the bank that is using it, instead of calling it by its real name: MIGS. Like one of the examples is AXNz in australia.