mymodule.module
<?php
/**
* Implementation of hook_menu().
*/
function mymodule_menu() {
$items['products'] = array(
'title' => 'Products',
'page callback' => 'products_by_categories',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Products By Categories Function
*/
function products_by_categories() {
return theme('products');
}
/**
* Implements hook_theme().
*/
function mymodule_theme() {
return array(
'products' => array(
'variables' => array(),
'template' => 'templates/products-template',
),
);
}
/**
* Implementation of hook_preprocess().
*/
function mymodule_preprocess(&$variables, $hook) {
if($hook == 'products') {
$products = db_select('product_with_categories', 'pwc')
->fields('pwc')
->execute()
->fetchAll();
$variables['results'] = $products;
}
}
?>
templates/products-template.tpl.php
<?php
//write any things and you get all info in $results variable which are defined in hook_preprocess function in .module file.
foreach ($results as $key => $value) {
}
?>
<?php
/**
* Implementation of hook_menu().
*/
function mymodule_menu() {
$items['products'] = array(
'title' => 'Products',
'page callback' => 'products_by_categories',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Products By Categories Function
*/
function products_by_categories() {
return theme('products');
}
/**
* Implements hook_theme().
*/
function mymodule_theme() {
return array(
'products' => array(
'variables' => array(),
'template' => 'templates/products-template',
),
);
}
/**
* Implementation of hook_preprocess().
*/
function mymodule_preprocess(&$variables, $hook) {
if($hook == 'products') {
$products = db_select('product_with_categories', 'pwc')
->fields('pwc')
->execute()
->fetchAll();
$variables['results'] = $products;
}
}
?>
templates/products-template.tpl.php
<?php
//write any things and you get all info in $results variable which are defined in hook_preprocess function in .module file.
foreach ($results as $key => $value) {
}
?>
Only MNC & established companies are using DFP(doubleclick for publishers) at this point. so learn doubleclick for publishers to get hired in these companies.
ReplyDelete