Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4239
Latest: 3dickulus
New This Month: 4
New This Week: 1
New Today: 0
Stats
Total Posts: 43126
Total Topics: 7500
Most Online Today: 83
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 29
Total: 29

Author Topic: Random Block  (Read 4005 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: 16378
    • 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
4941 Views
Last post June 18, 2010, 09:18:00 am
by dvera
1 Replies
4325 Views
Last post October 16, 2016, 12:12:51 pm
by exit
5 Replies
4327 Views
Last post July 12, 2017, 03:45:34 pm
by donk
8 Replies
6038 Views
Last post December 04, 2017, 09:41:20 pm
by Boomslanger
9 Replies
1129 Views
Last post April 05, 2022, 01:29:19 pm
by SMFHacks

+- Recent Topics

“Insert from Gallery” by apothocary
November 21, 2023, 07:25:28 am

SMFHacks Black Friday Sale 2023! by SMFHacks
November 19, 2023, 12:05:51 pm

File Count by SMFHacks
November 11, 2023, 11:46:46 am

Theme Changer by SMFHacks
November 09, 2023, 04:30:05 pm

Pretty Urls extras by SMFHacks
November 08, 2023, 05:23:14 pm

Member group access to emojis by SMFHacks
October 22, 2023, 07:24:12 am

Miscellaneous errors - don't know why by SMFHacks
October 13, 2023, 09:28:50 am

Follow / Follower Mod? by Nicole
October 06, 2023, 07:37:20 am

Mods supporting custom themes? by SMFHacks
October 02, 2023, 04:20:18 pm

Version 6.1.6 issues by SMFHacks
September 30, 2023, 07:54:52 am

Powered by EzPortal