it seems to work with the following patches:
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;
}
and change return of callback
print theme("page", $page_content);
to
return $page_content;
may need some more work.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | cafepress.module | 12.31 KB | anj |
Comments
Comment #1
pepiqueta commented...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 .= "
";
}//end if
$content .= "
";
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
Comment #2
rooey commentedthanks - i haven't had time to look into 4.7 yet - will put this on the back-burner.
Comment #3
lekei commentedIs this saying that Cafepress will work with Drupal if I make this change?
Is it possible to post the corrected file? I have a client who wants a Cafe Press store on her site. I was afraid I couldn't use Drupal for it.
Comment #4
rooey commentedComment #5
anj commentedI've attached a copy of the cafepress module, modified to run on Drupal 4.7. It seems to work, but it's awkward to use as you have to 'configure' it by sticking images with the right name in the right place! This is a feature of the original module, and nothing to do with the 4.7 version.
It would be better, and require less configuration, if it made use of the CafePress API (note that you need a free CafePress Affiliate account to use it). The new spreadshirt module works along these lines, and it may be possible (and indeed preferable) to add a CafePress 'back-end' there.
Comment #6
cardsup commentedI get this error when I install the module and try to active it in the blocks...
Fatal error: Call to a member function on a non-object in /home/site/public_html/modules/cafepress.module on line 159
Am I doing something wrong?
Comment #7
rooey commentedSorry folks, I don't have time to look into 4.7 support now - we skipped on to 5.0