cafepress module is used to display a block with cafepress stuff in it, and allow linking to those items for people to buy them.
Simply upload the images of your products from cafepress. Be sure to keep the name of each image the same as it's cafepress item number followed by .jpg");
break;
case "admin/modules/cafepress" :
// ANJ Correct path in this case statement?
$output = t("Set up the variables that allow the system to work. Make sure that you set the path correctly (check with your sys admin) and that you give a valid cafepress store id, or else it will not work.");
break;
case "admin/modules#description" :
$output = t("Enables admins to set up a block with cafepress items in it.");
break;
}//end swith/case
return $output;
}//end function
/** sytem hook. **//*
function cafepress_system($field) {
return t("cafe press");
}//end function
*/
function cafepress_settings() {
$form['cafepress_store_id'] = array(
'#type'=> 'textfield',
'#title' => t('Cafepress store id'),
'#required' => TRUE,
'#default_value' => variable_get("cafepress_store_id", ""),
'#size' => 70,
'#maxlength' => 255,
);
$form['cafepress_image_dir'] = array(
'#type'=> 'textfield',
'#title' => t('Cafepress images location'),
'#required' => TRUE,
'#default_value' => variable_get("cafepress_image_dir", "images/cafepress"),
'#size' => 70,
'#maxlength' => 255,
);
$form['cafepress_thumbnail_size'] = array(
'#type'=> 'textfield',
'#title' => t('Thumbnail size'),
'#required' => TRUE,
'#default_value' => variable_get("cafepress_thumbnail_size", "150"),
'#size' => 3,
'#maxlength' => 4,
);
$form['cafepress_num_cols'] = array(
'#type'=> 'textfield',
'#title' => t('The number of items to display in each row.'),
'#required' => TRUE,
'#default_value' => variable_get("cafepress_num_cols", "4"),
'#size' => 3,
'#maxlength' => 4,
);
$form['cafepress_store_link'] = array(
'#type' => 'select',
'#title' => t('Display link to store'),
'#default_value' => variable_get('cafepress_store_link', "Yes"),
'#options' => array(
1 => 'No',
2 => 'Yes',
),
'#description' => t('Should we display a link back to the cafepress store at the bottom of pages/blocks?'),
);
$form['cafepress_store_make'] = array(
'#type' => 'select',
'#title' => t('Show make store'),
'#default_value' => variable_get('cafepress_store_make', "No"),
'#options' => array(
1 => 'No',
2 => 'Yes',
),
'#description' => t('Should we display a referral link to allow users to make new cafepress stores?'),
);
return $form;
}
function cafepress_block($op = "list", $delta = 0) {
if ($op == "list") {
$result[0]["info"] = t("Cafepress block");
return $result;
}
else if ($op == "configure" && $delta == 0) {
$form['block_dummy'] = array(
'#type'=> 'textfield',
'#title' => t('Block configuration'),
'#required' => FALSE,
'#default_value' => variable_get("cafepress_block_dummy", "Nothing here yet"),
'#size' => 20,
'#maxlength' => 255,
);
return $form;
}
else if ($op == 'save' && $delta == 0) {
variable_set("cafepress_block_dummy", $edit["block_dummy"]);
}
else if ($op == 'view') {
if($delta != 0) {
return "Unknown block for this module.";
} else {
$cafepressId = variable_get("cafepress_store_id", "");
$image_size = variable_get("cafepress_thumbnail_size", "150");
$imageDir = variable_get("cafepress_image_dir", "images/cafepress");
$showStore = variable_get("cafepress_store_link", "Yes");
$makeStore = variable_get("cafepress_store_make", "No");
if($imageDir == "" || $cafepressId == "") {
return "Block not properly configured.";
}//end if
mt_srand((double)microtime()*1000000);
$imgs = dir($imageDir);
$a = array();
while($file = $imgs->read()) {
if(eregi(".gif", $file) || eregi(".jpg", $file) || eregi(".jpeg", $file)) {
$a[] = $file;
}//end if
}//end while
$random = mt_rand(0, sizeof($a) - 1);
$image = $a[$random];
$prodid = explode(".", $image);
if(($prodid) && ($image)) {
//$content = "";
$content .= "\n";
}//end if
$content .= "".l(t("more"), "onlinestore", array("title" => t("More stuff."))) ."";
if ($makeStore == "Yes" ) $content .= "Sell your stuff";
$block = array();
$block['subject'] = "Buy our stuff";
$block['content'] = $content;
return $block;
}//end if/else
}//end if/else
}//end function
/** Function to display the settings form. **/
function cafepress_old_settings() {
$output .= form_textfield(t("Cafepress store id"), "cafepress_store_id", variable_get("cafepress_store_id", ""), 70, 255, t("The store id given to you by cafepress when you signed up."));
$output .= form_textfield(t("Cafepress images location"), "cafepress_image_dir", variable_get("cafepress_image_dir", "images/cafepress"), 70, 255, t("The place where you uploaded the product images on the local server."));
$output .= form_textfield(t("Thumbnail size"), "cafepress_thumbnail_size", variable_get("cafepress_thumbnail_size", "150"), 3, 4, t("The size to show the items in the block."));
$output .= form_textfield(t("Display columns"), "cafepress_num_cols", variable_get("cafepress_num_cols", "4"), 3, 4, t("The number of items to display in each row."));
$output .= form_select(t('Display link to store'), 'cafepress_store_link', variable_get('cafepress_store_link', "Yes"), drupal_map_assoc(array("No", "Yes")), t('Should we display a link back to the cafepress store at the bottom of pages/blocks?'));
$output .= form_select(t('Show make store'), 'cafepress_store_make', variable_get('cafepress_store_make', "No"), drupal_map_assoc(array("No", "Yes")), t('Should we display a referral link to allow users to make new cafepress stores?'));
return $output;
}//end function
/** Function to display the block **/
function cafepress_old_block($op = "list", $delta = 0) {
if($op == "list") {
$result[0]["info"] = t("Cafepress block");
return $result;
} else {
if($delta != 0) {
return "Unknown block for this module.";
} else {
$cafepressId = variable_get("cafepress_store_id", "");
$image_size = variable_get("cafepress_thumbnail_size", "150");
$imageDir = variable_get("cafepress_image_dir", "images/cafepress");
$showStore = variable_get("cafepress_store_link", "Yes");
$makeStore = variable_get("cafepress_store_make", "No");
if($imageDir == "" || $cafepressId == "") {
return "Block not properly configured.";
}//end if
mt_srand((double)microtime()*1000000);
$imgs = dir($imageDir);
$a = array();
while($file = $imgs->read()) {
if(eregi(".gif", $file) || eregi(".jpg", $file) || eregi(".jpeg", $file)) {
$a[] = $file;
}//end if
}//end while
$random = mt_rand(0, sizeof($a) - 1);
$image = $a[$random];
$prodid = explode(".", $image);
if(($prodid) && ($image)) {
$content = "
Select an item to view more details...