Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4216
Latest: ezycc
New This Month: 0
New This Week: 2
New Today: 0
Stats
Total Posts: 42796
Total Topics: 7456
Most Online Today: 54
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 18
Total: 18

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

+- Recent Topics

Using SMF's Built-in Search Algorithm by shuban
March 27, 2023, 09:15:10 am

Permissions query by davejo
March 26, 2023, 04:43:48 am

prettyurls - TroubleShooting.wiki by SMFHacks
March 25, 2023, 01:49:35 pm

Download Gallery Option by SMFHacks
March 23, 2023, 09:34:02 am

Lost attachments by pete
March 22, 2023, 10:24:17 am

Additional Permissions by mickjav
March 18, 2023, 05:21:23 am

[Mod]Discord Web Hooks by SMFHacks
March 17, 2023, 08:48:30 am

Site upgrade to 2.1 by SMFHacks
March 12, 2023, 08:51:19 am

Theme/CSS design wanted by mickjav
March 11, 2023, 12:10:11 pm

Category Images by Anmer
March 10, 2023, 06:20:04 am

Powered by EzPortal