home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (uc_product.pages.inc)

This example Drupal source code file (uc_product.pages.inc) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, as, database, function, like, matches, node, php, result, sku, sql, string, strtolower, where

The uc_product.pages.inc Drupal example source code

<?php
// $Id: uc_product.pages.inc,v 1.1.2.8 2010/07/12 01:29:45 tr Exp $

/**
 * @file
 * Defines page callbacks for the product module.
 */

/**
 * Return an autocomplete list for product nodes.
 *
 * Using this autocomplete on a textfield will autocomplete based on product
 * titles or SKUs and leave the nid in the textfield.
 */
function uc_product_title_sku_autocomplete($string = '') {
  $matches = array();

  if ($string) {
    $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, p.model, p.unique_hash FROM {uc_products} AS p LEFT JOIN {node} AS n ON n.nid = p.nid WHERE p.unique_hash <> '' AND (LOWER(n.title) LIKE '%s%%' OR LOWER(p.model) LIKE '%s%%')"), strtolower($string), strtolower($string), 0, 10);
    while ($node = db_fetch_object($result)) {
      $matches[$node->nid] = t('@title [@sku]', array('@title' => $node->title, '@sku' => $node->model));
    }
  }

  drupal_json($matches);
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal uc_product.pages.inc source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.