collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 516
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Thanks for having an interest with our portal. If you have any requests for features, have a look at the Feature Requests board.

Author Topic: SMF Classifieds custom block - SMF 2.0.x  (Read 8205 times)

0 Members and 1 Guest are viewing this topic.

Offline vbgamer45

  • Semi Newbie
  • *
  • Posts: 5
    • SMFHacks.com
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
  • Elkarte Version: 1.1.4
SMF Classifieds custom block - SMF 2.0.x
« on: March 04, 2014, 02:34:54 PM »
Requested by one our users. Here is to share requires SMF Classifieds installed.
Works for SMF 2.0.x
Code below you must uncomment one of the blocks
Code: [Select]

//  ClassifiedsBlock(2,4, 'random','vertical');
//  ClassifiedsBlock(1,1, 'random','vertical');
  ClassifiedsBlock(2,4, 'random','horizonstal');



function ClassifiedsBlock($rows = 4, $listings = 4, $type = 'recent', $category = 0,  $format = 'vertical',  $startHtml = '', $endHtml = '')
{
global  $smcFunc, $scripturl, $txt, $modSettings, $boardurl, $user_info, $context, $sourcedir, $boarddir;

$rows = (int) $rows;
$listings = (int) $listings;
$category  = (int) $category;






// Html Header
echo $startHtml;


// Load the language files
if (loadlanguage('classifieds') == false)
loadLanguage('classifieds', 'english');

$g_manage = allowedTo('smfclassifieds_manage');

$groupsdata = implode($user_info['groups'],',');

if (empty($modSettings['class_url']))
$modSettings['class_url'] = $boardurl . '/classifieds/';

if (empty($modSettings['class_path']))
$modSettings['class_path'] = $boarddir . '/classifieds/';

$maxrowlevel = $rows;
echo '<table cellspacing="0" cellpadding="5" border="0" align="center" width="100%">

';
// Check what type it is
$query = ' ';
switch($type)
{
case 'recent':
$query = "SELECT i.ID_LISTING, i.commenttotal,
i.primaryID_PICTURE, i.title, p.thumbfilename, p.remotefilename, i.currentbid,i.currency,
i.datelisted, i.views, i.is_auction, i.totalbids, i.ID_CAT, c.noprice, i.expiredate
FROM {db_prefix}class_listing as i
LEFT JOIN {db_prefix}class_listing_pic as p ON (i.primaryID_PICTURE = p.ID_PICTURE)
LEFT JOIN {db_prefix}class_cat as c ON (i.ID_CAT = c.ID_CAT)
LEFT JOIN {db_prefix}class_catperm AS r ON (r.ID_GROUP IN ($groupsdata) AND r.ID_CAT = i.ID_CAT)
WHERE i.removed = 0 AND i.approved = 1  AND (r.view IS NULL || r.view =1) GROUP BY i.ID_LISTING ORDER BY i.ID_LISTING DESC LIMIT $listings";
break;

case 'viewed':
$query = "SELECT i.ID_LISTING, i.commenttotal,
i.primaryID_PICTURE, i.title, p.thumbfilename, p.remotefilename, i.currentbid,i.currency,
i.datelisted, i.views, i.is_auction, i.totalbids, i.ID_CAT, c.noprice, i.expiredate
FROM {db_prefix}class_listing as i
LEFT JOIN {db_prefix}class_listing_pic as p ON (i.primaryID_PICTURE = p.ID_PICTURE)
LEFT JOIN {db_prefix}class_cat as c ON (i.ID_CAT = c.ID_CAT)
LEFT JOIN {db_prefix}class_catperm AS r ON (r.ID_GROUP IN ($groupsdata) AND r.ID_CAT = i.ID_CAT)
WHERE i.removed = 0 AND i.approved = 1  AND (r.view IS NULL || r.view =1) GROUP BY i.ID_LISTING ORDER BY  i.views DESC LIMIT $listings";
break;
               
  case 'random':
$query = "SELECT i.ID_LISTING, i.commenttotal,
i.primaryID_PICTURE, i.title, p.thumbfilename, p.remotefilename, i.currentbid,i.currency,
i.datelisted, i.views, i.is_auction, i.totalbids, i.ID_CAT, c.noprice, i.expiredate
FROM {db_prefix}class_listing as i
LEFT JOIN {db_prefix}class_listing_pic as p ON (i.primaryID_PICTURE = p.ID_PICTURE)
LEFT JOIN {db_prefix}class_cat as c ON (i.ID_CAT = c.ID_CAT)
LEFT JOIN {db_prefix}class_catperm AS r ON (r.ID_GROUP IN ($groupsdata) AND r.ID_CAT = i.ID_CAT)
WHERE i.removed = 0 AND i.approved = 1  AND (r.view IS NULL || r.view =1) GROUP BY i.ID_LISTING ORDER BY  RAND() DESC LIMIT $listings";
break;
               

case 'mostcomments':
$query = "SELECT i.ID_LISTING, i.commenttotal,
i.primaryID_PICTURE, i.title, p.thumbfilename, p.remotefilename, i.currentbid,i.currency,
i.datelisted, i.views, i.is_auction, i.totalbids, i.ID_CAT, c.noprice, i.expiredate
FROM {db_prefix}class_listing as i
LEFT JOIN {db_prefix}class_listing_pic as p ON (i.primaryID_PICTURE = p.ID_PICTURE)
LEFT JOIN {db_prefix}class_cat as c ON (i.ID_CAT = c.ID_CAT)
LEFT JOIN {db_prefix}class_catperm AS r ON (r.ID_GROUP IN ($groupsdata) AND r.ID_CAT = i.ID_CAT)
WHERE i.removed = 0 AND i.approved = 1  AND (r.view IS NULL || r.view =1) GROUP BY i.ID_LISTING ORDER BY i.commenttotal DESC LIMIT $listings";
break;

case 'featured':
$query = "SELECT i.ID_LISTING, i.commenttotal,
i.primaryID_PICTURE, i.title, p.thumbfilename, p.remotefilename, i.currentbid,i.currency,
i.datelisted, i.views, i.is_auction, i.totalbids, i.ID_CAT, c.noprice, i.expiredate
FROM {db_prefix}class_listing as i
LEFT JOIN {db_prefix}class_listing_pic as p ON (i.primaryID_PICTURE = p.ID_PICTURE)
LEFT JOIN {db_prefix}class_cat as c ON (i.ID_CAT = c.ID_CAT)
LEFT JOIN {db_prefix}class_catperm AS r ON (r.ID_GROUP IN ($groupsdata) AND r.ID_CAT = i.ID_CAT)
WHERE i.removed = 0 AND i.approved = 1 AND i.featuredlisting = 1  AND (r.view IS NULL || r.view =1) GROUP BY i.ID_LISTING ORDER BY i.ID_LISTING DESC LIMIT $listings";
break;


}
// Execute the SQL query
$dbresult = $smcFunc['db_query']('', $query);
$rowlevel = 0;
while($row = $smcFunc['db_fetch_assoc']($dbresult))
{
if ($rowlevel == 0)
echo '<tr class="windowbg2">';

echo '<td align="center"><a href="', $scripturl, '?action=classifieds;sa=view;id=', $row['ID_LISTING'], '">', $row['title'], '</a><br />';

if (!empty($row['primaryID_PICTURE']) && $modSettings['class_catlist_showimage'])
{

if (empty($row['remotefilename']))
echo '<a href="', $scripturl, '?action=classifieds;sa=view;id=', $row['ID_LISTING'], '"><img src="', $modSettings['class_url'], $row['thumbfilename'], '" alt="" /></a><br />';
else
echo '<a href="', $scripturl, '?action=classifieds;sa=view;id=', $row['ID_LISTING'], '"><img src="', $row['remotefilename'], '" alt="" /></a><br />';

}

echo '<span class="smalltext">';


if (!empty($modSettings['class_catlist_currentprice']) && $row['noprice'] == 0)
echo $txt['class_text_price'] . SMFEzformatprice($row['currentbid'],$row['currency']) . '<br />';


if (!empty($modSettings['class_catlist_listingdate']))
            {
                if (!empty($modSettings['class_set_date_format_mdy']))
                    echo $txt['class_text_date'] .  date($modSettings['class_set_date_format_mdy'],$row['datelisted']), ' ', date($modSettings['class_set_date_format_hia'],$row['datelisted']) . '<br />';
                else
                    echo $txt['class_text_date'] . date("m/d/Y",$row['datelisted']) . ' ' . date("h:i a",$row['datelisted'])  . '<br />';
           
            }




if ($modSettings['class_catlist_timeleft'])
{
echo  $txt['class_txt_time_left'] ;

echo   ($row['expiredate'] == 0 ? $txt['class_expire_never'] :   SMFezblockclass_cattimeleft( date("Y",$row['expiredate']), date("m",$row['expiredate']), date("d",$row['expiredate']), date("H",$row['expiredate']), date("i",$row['expiredate']),date("s",$row['expiredate'])) ) , '<br />';

}



if (!empty($modSettings['class_catlist_numofbids']) && $row['noprice'] == 0 && $row['is_auction'] == 1)
echo $txt['class_text_totalbids'] . ' ' . $row['totalbids'] . '<br />';


if (!empty($modSettings['class_catlist_comments']))
echo $txt['class_text_comments'] . ' (<a href="' . $scripturl . '?action=classifieds;sa=view;id=' . $row['ID_LISTING'] . '">' . $row['commenttotal'] . '</a>)<br />';

if ($g_manage)
{
if ($row['is_auction'] == 0)
echo '&nbsp;<a href="' . $scripturl . '?action=classifieds;sa=editlisting;id=' . $row['ID_LISTING'] . '">' . $txt['class_text_edit'] . '</a>';
else
echo '&nbsp;<a href="' . $scripturl . '?action=classifieds;sa=editauction;id=' . $row['ID_LISTING'] . '">' . $txt['class_text_edit'] . '</a>';


echo '&nbsp;<a href="' . $scripturl . '?action=classifieds;sa=deletelisting;id=' . $row['ID_LISTING'] . '">' . $txt['class_text_delete'] . '</a>';

}

echo '</span></td>';


if($rowlevel < ($maxrowlevel-1))
$rowlevel++;
else
{
echo '</tr>';
$rowlevel = 0;
}
}
if($rowlevel !=0)
{
echo '</tr>';
}

echo '
      </table><br />';
// Free the Mysql Resoruces
$smcFunc['db_free_result']($dbresult);

// Html Footer
echo $endHtml;

}
function SMFEzformatprice($price,$currency)
{
if ($currency == 'USD')
return  '$' .  number_format($price, 2, '.', '');
else if ($currency == 'GBP')
return  '£' .  number_format($price, 2, '.', '');
elseif ($currency == 'CAD')
return  '$' .  number_format($price, 2, '.', '');
elseif ($currency == 'AUD')
return  '$' .  number_format($price, 2, '.', '');
  elseif ($currency == 'ZAR')
return  'R ' .  number_format($price, 2, '-', '');
else
return $price . ' ' . $currency;

}


function SMFezblockclass_cattimeleft($year, $month, $day, $hour, $minute, $seconds)
{
global $txt;
  // make a unix timestamp for the given date
  $the_countdown_date = mktime($hour, $minute, $seconds, $month, $day, $year, -1);

  // get current unix timestamp
  $today = forum_time(false);
 

  $difference = $the_countdown_date - $today;
  if ($difference < 0) $difference = 0;

  $days_left = floor($difference/60/60/24);
  $hours_left = floor(($difference - $days_left*60*60*24)/60/60);
  $minutes_left = floor(($difference - $days_left*60*60*24 - $hours_left*60*60)/60);
  $seconds_left = floor(($difference - $days_left*60*60*24 - $hours_left*60*60 - $minutes_left*60));


 
  if ($days_left == 0 && $hours_left == 0 &&  $minutes_left < 5  && ($minutes_left != 0 && $seconds_left  !=0))
  {
  echo '<font color="#FF0000">';
  }
 
  echo '<span class="smalltext">';
 
  if ($days_left > 0)
  {
  echo $days_left . 'd ' . $hours_left  . 'h ' . $minutes_left . 'm';
  }
  else
  {
  if ($hours_left > 0)
  echo $hours_left  . 'h ' . $minutes_left . 'm';
  else
  {
 
  if ($minutes_left > 0)
  echo $minutes_left . 'm ' . $seconds_left . 's';
  else
  {
  if ($seconds_left > 0)
  echo  $seconds_left . 's';
 
  }
 
 
  }
   
  }
 

  echo '</span>';
   
  if ($days_left == 0 && $hours_left == 0 &&  $minutes_left < 5  && ($minutes_left != 0 && $seconds_left  !=0))
  {
  echo '</font>';
  }
 
}
« Last Edit: March 16, 2014, 08:17:12 AM by vbgamer45 »
https://www.smfhacks.com - Products and Modifications for SMF

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: SMF Classifieds custom block - SMF 2.0.x
« Reply #1 on: March 04, 2014, 02:50:18 PM »
Thank you very much for sharing this! I really appreciate it. :)
And slowly, you come to realize... It's all as it should be...

Offline vbgamer45

  • Semi Newbie
  • *
  • Posts: 5
    • SMFHacks.com
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
  • Elkarte Version: 1.1.4
Re: SMF Classifieds custom block - SMF 2.0.x
« Reply #2 on: March 04, 2014, 02:58:05 PM »
Thank you very much for sharing this! I really appreciate it. :)
I can post more if needed pretty easy to convert over the functions I have.
Wasn't sure on the format: Looks like you have custom code php and plugins as well.
https://www.smfhacks.com - Products and Modifications for SMF

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: SMF Classifieds custom block - SMF 2.0.x
« Reply #3 on: March 04, 2014, 03:10:05 PM »
It'd be great if you could post the block codes for your other mods, particularly for the ones that are not available on the sm.org Mod Site. I know we got plenty of block code requests for those.

We just need your regular plain PHP code. So what you have above works pretty well.
And slowly, you come to realize... It's all as it should be...

Offline USFA

  • Semi Newbie
  • *
  • Posts: 43
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: SMF Classifieds custom block - SMF 2.0.x
« Reply #4 on: May 27, 2014, 04:55:26 PM »
Is there a free classifieds for smf ??

Offline renoldscott

  • Semi Newbie
  • *
  • Posts: 5
  • Gender: Male
    • Whitepaper IT - Open Source Web Development
Re: SMF Classifieds custom block - SMF 2.0.x
« Reply #5 on: June 09, 2014, 03:31:25 AM »
Thanks for share this amazing and useful code.