I downloaded some blocks for PN_Zclassifieds and I can't figure out how to edit them to allow for a prefix:
Here are the instructions:
Quote
all the blocks and module is based on database names like "classifieds_" not "nuke_classifieds_". If you use tables name like "nuke_classifieds_" you must check all blocks files to change it from "classifieds_" to ".$prefix."_classifieds_"
I don't know which item/s to change, I thought there was one instance that defined what the database looked for anyways here is a sample of the code:
Code
$blocks_modules['zclassifieds_lastads_img'] = array(
'func_display' => 'blocks_zclassifieds_lastads_img_block',
'func_edit' => 'blocks_zclassifieds_lastads_img_select',
'func_update' => 'blocks_zclassifieds_lastads_img_update',
'text_type' => 'PN_zclassifieds_lastads_img',
'text_type_long' => 'PN_zclassifieds : Last Ads With Thumbnails',
'allow_multiple' => true,
'form_content' => false,
'form_refresh' => false,
'show_preview' => true
);
pnSecAddSchema("PN_zClassifieds_LastAds_img::", "Block title::");
function blocks_zclassifieds_lastads_img_block($row)
{
if (!authorised(0, "PN_zClassifieds_LastAds_img::", "$row[title]::", ACCESS_READ)) {
return;
}
global $prefix;
// Break out options from our content field
$vars = pnBlockVarsFromContent($row['content']);
if (!empty($vars['nbads'])) $nbads = $vars['nbads']; else $nbads = 0;
if (!empty($vars['thumbsize'])) $thumbsize = $vars['thumbsize'];
if (!empty($vars['maxtitle'])) $maxtitle = $vars['maxtitle'];
if (!empty($vars['zclmodulename'])) $zclmodulename = $vars['zclmodulename']; else $zclmodulename = "PN_zClassifieds";
$time = time();
$currentlang = pnUserGetLang();
require("modules/$zclmodulename/vars.php");
$sql = "SELECT DISTINCT a.ad_id, a.cat_id, a.descript, a.subject, a.type, a.price
FROM classifieds_ads a, classifieds_category c, classifieds_photo p";
$sql .= " WHERE a.cat_id=c.root_id AND (c.lang='$currentlang' OR lang='') AND a.exp_date>$time AND a.valid=1 AND a.ad_id=p.ad_id";
$sql .= " ORDER BY a.add_date DESC LIMIT $nbads";
$result = mysql_query( $sql );
if( mysql_num_rows( $result ) == 0 )
$content = "<center>"._NOADS."</center>";
else
{
$content = "<table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" border=\"0\">\n";
while(list($ad_id, $cat_id, $descript, $subject, $type, $price) = mysql_fetch_row( $result ))
{
$subject_title = $subject;
if($maxtitle != "") {
if( strlen( $subject ) > $maxtitle ) {
$subject = substr( $subject, 0, $maxtitle );
$subject .= " ...";
}
}
$content .= "<tr><td valign=\"top\" align=\"left\">\n";
$photo = mysql_query("SELECT photo_id FROM classifieds_photo WHERE ad_id='$ad_id' LIMIT 1") or error(mysql_error());
if (mysql_num_rows($photo) != 0)
{
list($photo_id) = mysql_fetch_row($photo);
if($thumbsize > 0) {
if (file_exists("modules/$zclmodulename/myimages/thumb/$photo_id.jpg")) {
$size = @getimagesize("modules/$zclmodulename/myimages/thumb/$photo_id.jpg");
$im_width=$size[0];
$im_height=$size[1];
// work out new sizes
/*if($im_width >= $im_height)
{
$factor = $thumbsize/$im_width;
$new_width = $thumbsize;
$new_height = $im_height * $factor;
}
else
{
$factor = $thumbsize/$im_height;
$new_height = $thumbsize;
$new_width = $im_width * $factor;
}*/
$factor = $thumbsize/$im_width;
$new_width = $thumbsize;
$new_height = $im_height * $factor;
$content .= "<a href=\"modules.php?op=modload&name=$zclmodulename&file=detail&cat=$cat_id&de=$ad_id\"><img src=\"modules/$zclmodulename/myimages/thumb/$photo_id.jpg\" width=\"$new_width\" height=\"$new_height\" border=\"0\" alt=\""._CLICKMOREDETAILS."\"></a>";
}
}
else
$content .= "<a href=\"modules.php?op=modload&name=$zclmodulename&file=detail&cat=$cat_id&de=$ad_id\"><img src=\"modules/$zclmodulename/myimages/thumb/$photo_id.jpg\" border=\"0\" alt=\""._CLICKMOREDETAILS."\"></a>";
}
$content .= "</td>\n";
$content .= "<td valign=top>";
$content .= "<span class=\"pn-normal\">\n";
$content .= "<a title=\"$subject_title\" href=\"modules.php?op=modload&name=$zclmodulename&file=detail&cat=$cat_id&de=$ad_id\">$subject</a>";
$content .= "</span>\n";
$content .= "<br>\n";
if($price >0) {
$price = blockadimgformatPrice($price, $zclmodulename);
$pos_price = $POS_PRICE[$currentlang];
$content .= "<span class=\"pn-normal\">\n";
if($pos_price == 'right')
$content .= "$price"._MONEY."\n";
else
$content .= ""._MONEY."$price\n";
$content .= "</span>";
}
$content .= "</td></tr>\n";
}
$content .= "</table>\n";
/*$content .= "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" border=\"0\">\n";
$content .= "<tr><td align=center>\n";
$content .= "<br>";
//$content .= "<span class=\"pn-normal\">\n";
$content .= "<a href=\"modules.php?op=modload&name=$zclmodulename&file=index\">"._HOMEADS."</a>\n";
//$content .= "</span>";
$content .= "</td></tr>\n";
$content .= "</table>\n"; */
}
if (empty($row['title'])) {
$row['title'] = _BLOCKTITLELASTADSIMG;
}
$row['content'] = $content;
return themesideblock($row);
}
function blocks_zclassifieds_lastads_img_select($row)
{
// Break out options from our content field
$vars = pnBlockVarsFromContent($row['content']);
$row['content'] = "";
if($vars['zclmodulename'] == "") $zclmodulename = "PN_zClassifieds";
else $zclmodulename = pnVarPrepForDisplay($vars['zclmodulename']);
$result = mysql_query( "SELECT root_id FROM classifieds_category WHERE papa_id=0" ) or error( mysql_error() );
$output .= "<tr><td class=\"pn-normal\">"._MODULENAME." :</td><td><input type=\"text\" name=\"zclmodulename\" size=\"20\" value=\"$zclmodulename\"></td></tr>";
$output .= "<tr><td class=\"pn-normal\">"._NBADS." :</td><td><input type=\"text\" name=\"nbads\" size=\"15\" value=\"" . pnVarPrepForDisplay($vars['nbads']) . "\"></td></tr>";
$output .= "<tr><td class=\"pn-normal\">"._MAXTITLE." :</td><td><input type=\"text\" name=\"maxtitle\" size=\"15\" value=\"" . pnVarPrepForDisplay($vars['maxtitle']) . "\"></td></tr>";
$output .= "<tr><td class=\"pn-normal\">"._THUMBSIZE." :</td><td><input type=\"text\" name=\"thumbsize\" size=\"15\" value=\"" . pnVarPrepForDisplay($vars['thumbsize']) . "\"></td></tr>";
return $output;
}
function blocks_zclassifieds_lastads_img_update($row)
{
$vars['zclmodulename'] = pnVarCleanFromInput('zclmodulename');
$vars['nbads'] = pnVarCleanFromInput('nbads');
$vars['thumbsize'] = pnVarCleanFromInput('thumbsize');
$vars['maxtitle'] = pnVarCleanFromInput('maxtitle');
$vars['thumbsize'] = pnVarCleanFromInput('thumbsize');
$row['content'] = pnBlockVarsToContent($vars);
return($row);
}
function blockadimgformatPrice($inum, $zclmodulename){
global $ModName;
require("modules/$zclmodulename/vars.php");
$currentlang = pnUserGetLang();
if( (!isset($inum)) || (empty($inum)) || ($inum=='')) {
return '';
}
$returnValue = '';
//here you have to read the the value from vars.php!!!
$dateformat = $PRICE_FORMAT[$currentlang];
if ($dateformat == '9.999,99') {
$returnValue = number_format($inum,$PRICE_DEC,',','.');
}
else {
$returnValue = number_format($inum,$PRICE_DEC,'.',',');
}
return $returnValue;
}
?>
'func_display' => 'blocks_zclassifieds_lastads_img_block',
'func_edit' => 'blocks_zclassifieds_lastads_img_select',
'func_update' => 'blocks_zclassifieds_lastads_img_update',
'text_type' => 'PN_zclassifieds_lastads_img',
'text_type_long' => 'PN_zclassifieds : Last Ads With Thumbnails',
'allow_multiple' => true,
'form_content' => false,
'form_refresh' => false,
'show_preview' => true
);
pnSecAddSchema("PN_zClassifieds_LastAds_img::", "Block title::");
function blocks_zclassifieds_lastads_img_block($row)
{
if (!authorised(0, "PN_zClassifieds_LastAds_img::", "$row[title]::", ACCESS_READ)) {
return;
}
global $prefix;
// Break out options from our content field
$vars = pnBlockVarsFromContent($row['content']);
if (!empty($vars['nbads'])) $nbads = $vars['nbads']; else $nbads = 0;
if (!empty($vars['thumbsize'])) $thumbsize = $vars['thumbsize'];
if (!empty($vars['maxtitle'])) $maxtitle = $vars['maxtitle'];
if (!empty($vars['zclmodulename'])) $zclmodulename = $vars['zclmodulename']; else $zclmodulename = "PN_zClassifieds";
$time = time();
$currentlang = pnUserGetLang();
require("modules/$zclmodulename/vars.php");
$sql = "SELECT DISTINCT a.ad_id, a.cat_id, a.descript, a.subject, a.type, a.price
FROM classifieds_ads a, classifieds_category c, classifieds_photo p";
$sql .= " WHERE a.cat_id=c.root_id AND (c.lang='$currentlang' OR lang='') AND a.exp_date>$time AND a.valid=1 AND a.ad_id=p.ad_id";
$sql .= " ORDER BY a.add_date DESC LIMIT $nbads";
$result = mysql_query( $sql );
if( mysql_num_rows( $result ) == 0 )
$content = "<center>"._NOADS."</center>";
else
{
$content = "<table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" border=\"0\">\n";
while(list($ad_id, $cat_id, $descript, $subject, $type, $price) = mysql_fetch_row( $result ))
{
$subject_title = $subject;
if($maxtitle != "") {
if( strlen( $subject ) > $maxtitle ) {
$subject = substr( $subject, 0, $maxtitle );
$subject .= " ...";
}
}
$content .= "<tr><td valign=\"top\" align=\"left\">\n";
$photo = mysql_query("SELECT photo_id FROM classifieds_photo WHERE ad_id='$ad_id' LIMIT 1") or error(mysql_error());
if (mysql_num_rows($photo) != 0)
{
list($photo_id) = mysql_fetch_row($photo);
if($thumbsize > 0) {
if (file_exists("modules/$zclmodulename/myimages/thumb/$photo_id.jpg")) {
$size = @getimagesize("modules/$zclmodulename/myimages/thumb/$photo_id.jpg");
$im_width=$size[0];
$im_height=$size[1];
// work out new sizes
/*if($im_width >= $im_height)
{
$factor = $thumbsize/$im_width;
$new_width = $thumbsize;
$new_height = $im_height * $factor;
}
else
{
$factor = $thumbsize/$im_height;
$new_height = $thumbsize;
$new_width = $im_width * $factor;
}*/
$factor = $thumbsize/$im_width;
$new_width = $thumbsize;
$new_height = $im_height * $factor;
$content .= "<a href=\"modules.php?op=modload&name=$zclmodulename&file=detail&cat=$cat_id&de=$ad_id\"><img src=\"modules/$zclmodulename/myimages/thumb/$photo_id.jpg\" width=\"$new_width\" height=\"$new_height\" border=\"0\" alt=\""._CLICKMOREDETAILS."\"></a>";
}
}
else
$content .= "<a href=\"modules.php?op=modload&name=$zclmodulename&file=detail&cat=$cat_id&de=$ad_id\"><img src=\"modules/$zclmodulename/myimages/thumb/$photo_id.jpg\" border=\"0\" alt=\""._CLICKMOREDETAILS."\"></a>";
}
$content .= "</td>\n";
$content .= "<td valign=top>";
$content .= "<span class=\"pn-normal\">\n";
$content .= "<a title=\"$subject_title\" href=\"modules.php?op=modload&name=$zclmodulename&file=detail&cat=$cat_id&de=$ad_id\">$subject</a>";
$content .= "</span>\n";
$content .= "<br>\n";
if($price >0) {
$price = blockadimgformatPrice($price, $zclmodulename);
$pos_price = $POS_PRICE[$currentlang];
$content .= "<span class=\"pn-normal\">\n";
if($pos_price == 'right')
$content .= "$price"._MONEY."\n";
else
$content .= ""._MONEY."$price\n";
$content .= "</span>";
}
$content .= "</td></tr>\n";
}
$content .= "</table>\n";
/*$content .= "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" border=\"0\">\n";
$content .= "<tr><td align=center>\n";
$content .= "<br>";
//$content .= "<span class=\"pn-normal\">\n";
$content .= "<a href=\"modules.php?op=modload&name=$zclmodulename&file=index\">"._HOMEADS."</a>\n";
//$content .= "</span>";
$content .= "</td></tr>\n";
$content .= "</table>\n"; */
}
if (empty($row['title'])) {
$row['title'] = _BLOCKTITLELASTADSIMG;
}
$row['content'] = $content;
return themesideblock($row);
}
function blocks_zclassifieds_lastads_img_select($row)
{
// Break out options from our content field
$vars = pnBlockVarsFromContent($row['content']);
$row['content'] = "";
if($vars['zclmodulename'] == "") $zclmodulename = "PN_zClassifieds";
else $zclmodulename = pnVarPrepForDisplay($vars['zclmodulename']);
$result = mysql_query( "SELECT root_id FROM classifieds_category WHERE papa_id=0" ) or error( mysql_error() );
$output .= "<tr><td class=\"pn-normal\">"._MODULENAME." :</td><td><input type=\"text\" name=\"zclmodulename\" size=\"20\" value=\"$zclmodulename\"></td></tr>";
$output .= "<tr><td class=\"pn-normal\">"._NBADS." :</td><td><input type=\"text\" name=\"nbads\" size=\"15\" value=\"" . pnVarPrepForDisplay($vars['nbads']) . "\"></td></tr>";
$output .= "<tr><td class=\"pn-normal\">"._MAXTITLE." :</td><td><input type=\"text\" name=\"maxtitle\" size=\"15\" value=\"" . pnVarPrepForDisplay($vars['maxtitle']) . "\"></td></tr>";
$output .= "<tr><td class=\"pn-normal\">"._THUMBSIZE." :</td><td><input type=\"text\" name=\"thumbsize\" size=\"15\" value=\"" . pnVarPrepForDisplay($vars['thumbsize']) . "\"></td></tr>";
return $output;
}
function blocks_zclassifieds_lastads_img_update($row)
{
$vars['zclmodulename'] = pnVarCleanFromInput('zclmodulename');
$vars['nbads'] = pnVarCleanFromInput('nbads');
$vars['thumbsize'] = pnVarCleanFromInput('thumbsize');
$vars['maxtitle'] = pnVarCleanFromInput('maxtitle');
$vars['thumbsize'] = pnVarCleanFromInput('thumbsize');
$row['content'] = pnBlockVarsToContent($vars);
return($row);
}
function blockadimgformatPrice($inum, $zclmodulename){
global $ModName;
require("modules/$zclmodulename/vars.php");
$currentlang = pnUserGetLang();
if( (!isset($inum)) || (empty($inum)) || ($inum=='')) {
return '';
}
$returnValue = '';
//here you have to read the the value from vars.php!!!
$dateformat = $PRICE_FORMAT[$currentlang];
if ($dateformat == '9.999,99') {
$returnValue = number_format($inum,$PRICE_DEC,',','.');
}
else {
$returnValue = number_format($inum,$PRICE_DEC,'.',',');
}
return $returnValue;
}
?>
I tried to do a search on classifieds_ but I don't think that will work right... any suggestions?
Thanks
