Facebook 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4290
Latest: JoshuaShoor
New This Month: 2
New This Week: 0
New Today: 0
Stats
Total Posts: 43790
Total Topics: 7602
Most Online Today: 57
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 1
Guests: 61
Total: 62

Author Topic: Random Block  (Read 5367 times)

0 Members and 1 Guest are viewing this topic.

Offline clothahump

  • Jr. Member
  • **
  • Posts: 86
    • View Profile
Random Block
« on: November 01, 2010, 03:40:58 am »
Implemented the random block for TP, is there an easy way to use one of the blocks that came with Gallery Pro instead as they look neater, comparison below.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16673
    • View Profile
Re: Random Block
« Reply #1 on: November 01, 2010, 01:09:06 pm »
One issue I see is it looks like the thumbnails in the first picture are different sizes which would cause it to be formatted differently.

Here is another example that uses block a code for random images

Code: [Select]
//Start SMF Gallery
global $sourcedir ;
require_once($sourcedir . '/Subs-Gallery2.php');

if (!$context['user']['is_guest'])
$groupsdata = implode($user_info['groups'], ',');
else
$groupsdata = -1;

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

$txt['lang_locale'] = 'en_US';

$dbresult =  $smcFunc['db_query']('', "
SELECT
p.ID_PICTURE, p.commenttotal, p.filesize, p.views, p.thumbfilename, p.title, p.ID_MEMBER,
m.real_name, p.date, p.mature, c.view, p.rating, p.totalratings 
FROM {db_prefix}gallery_pic as p
LEFT JOIN {db_prefix}members AS m ON (m.id_member = p.id_member)
LEFT JOIN {db_prefix}gallery_usersettings AS s ON (s.id_member = m.id_member)
LEFT JOIN {db_prefix}gallery_catperm AS c ON (c.id_group IN ($groupsdata) AND c.id_cat = p.id_cat)
WHERE ((s.private = 0 || s.private IS NULL) AND (s.password = '' || s.password IS NULL) AND p.user_id_cat != 0 AND p.approved = 1) || (p.approved = 1 AND p.user_id_cat = 0 AND (c.view IS NULL || c.view = 1))
GROUP BY p.ID_PICTURE  ORDER BY RAND() LIMIT 4");

$context['gallery_recent'] = array();
while($row = $smcFunc['db_fetch_assoc']($dbresult))
{
// Check for mature images
if ($row['mature'] == 1)
{
if (CanViewMature() == false)
$row['thumbfilename'] = 'mature.gif';
}


$context['gallery_recent'][] = array(
'id_picture' => $row['ID_PICTURE'],
'totalratings' => $row['totalratings'],
'rating' => $row['rating'],
'title' => $row['title'],
'thumbfilename' =>  $row['thumbfilename'],
'views' => $row['views'],
'filesize' => round($row['filesize'] / 1024, 2) . 'kb',
'date' => timeformat($row['date']),
'commenttotal' => $row['commenttotal'],
'commentlink' => ' (<a href="' . $scripturl . '?action=gallery;sa=view;id=' . $row['ID_PICTURE'] . '">' . $row['commenttotal'] . '</a>)<br />',
'profilelink' => !empty($row['real_name']) ? ' <a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">'  . $row['real_name'] . '</a><br />' : $txt['gallery_text_by'] . ' ' . $txt['gallery_guest'] . '<br />',
);

}
$smcFunc['db_free_result']($dbresult);
//END SMF Gallery


// SMF Gallery Recent Images on Index
global $boardurl;




// Check if the gallery url has been set if not use the default
if(empty($modSettings['gallery_url']))
$modSettings['gallery_url'] = $boardurl . '/gallery/';

echo '<table cellspacing="0" cellpadding="5" border="0" align="center" width="90%" class="tborder">
<tr class="titlebg">
<td align="center" colspan="4">',  $txt['gallery_main_recent'] ,'</td>
</tr>
';
$rowlevel = 0;
$maxrowlevel = 4;
foreach ($context['gallery_recent'] as $picture)
{

if ($rowlevel == 0)
echo '<tr>';


echo '
<td align="center"><a href="' . $scripturl . '?action=gallery;sa=view;id=' .$picture['id_picture'] . '"><img src="' . $modSettings['gallery_url'] . $picture['thumbfilename']  . '" alt="" /></a><br />
<span class="smalltext">';
if (!empty($modSettings['gallery_set_t_rating']))
{
if ($gallerySettings['gallery_points_instead_stars'])
echo $txt['gallery_form_rating'] . $picture['rating'] . '<br />';
else
echo $txt['gallery_form_rating'] . GetStarsByPercent(($picture['totalratings'] != 0) ? ($picture['rating'] / ($picture['totalratings'] * 5) * 100) : 0) . '<br />';
}

if (!empty($modSettings['gallery_set_t_views']))
echo $txt['gallery_text_views'] . $picture['views'] . '<br />';
if (!empty($modSettings['gallery_set_t_filesize']))
echo $txt['gallery_text_filesize'] . $picture['filesize'] . '<br />';
if (!empty($modSettings['gallery_set_t_date']))
echo $txt['gallery_text_date'] . $picture['date'] . '<br />';
if (!empty($modSettings['gallery_set_t_comment']))
echo $txt['gallery_text_comments'] . $picture['commentlink'];
if (!empty($modSettings['gallery_set_t_username']))
{
echo $txt['gallery_text_by'] . $picture['profilelink'];

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



if($rowlevel < ($maxrowlevel-1))
$rowlevel++;
else
{
echo '</tr>';
$rowlevel = 0;
}
}
if($rowlevel !=0)
{
echo '</tr>';
}
echo '</table>';
// End SMF Gallery Recent Images on Index
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline clothahump

  • Jr. Member
  • **
  • Posts: 86
    • View Profile
Re: Random Block
« Reply #2 on: November 01, 2010, 01:32:28 pm »
That code blanked the forum out completely.  :'(

 

Related Topics

  Subject / Started by Replies Last post
4 Replies
6544 Views
Last post June 18, 2010, 09:18:00 am
by dvera
1 Replies
5757 Views
Last post October 16, 2016, 12:12:51 pm
by exit
5 Replies
5713 Views
Last post July 12, 2017, 03:45:34 pm
by donk
8 Replies
7725 Views
Last post December 04, 2017, 09:41:20 pm
by Boomslanger
9 Replies
2168 Views
Last post April 05, 2022, 01:29:19 pm
by SMFHacks

+- Recent Topics

[Mod]Cloudflare Turnstile for SMF by SMFHacks
May 08, 2025, 10:08:43 am

Disable "Notify me of Comments feature" by Kiwi
May 08, 2025, 02:04:16 am

Trying to access array offset on null by Michel68
May 05, 2025, 08:47:34 am

Default [Additional] Membergroups upon Registration by SMFHacks
April 30, 2025, 10:22:52 am

Sorted FTP Import Directory by SMFHacks
April 25, 2025, 05:11:22 am

Search results items per page? by SMFHacks
April 18, 2025, 04:12:23 pm

Suggestions and request by Senkusha
April 03, 2025, 02:30:43 pm

How does a member add a Classified Listing? by SMFHacks
March 28, 2025, 08:05:50 pm

Auto converting to webp or AVIF by [chrisB]
March 28, 2025, 01:46:00 pm

Thumbnail creation settings by SMFHacks
March 28, 2025, 12:42:51 pm

Powered by EzPortal