Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4274
Latest: kellanphil
New This Month: 3
New This Week: 1
New Today: 0
Stats
Total Posts: 43645
Total Topics: 7572
Most Online Today: 83
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 72
Total: 72

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

+- Recent Topics

Ability to exclude categories from ezPortal SMF Gallery random image ezblock by Alistair
January 22, 2025, 08:20:13 am

How to move SMF to new server by SMFHacks
January 21, 2025, 08:45:53 pm

Figuring out settings by SMFHacks
January 12, 2025, 04:56:14 pm

Filesizes incorrect by SMFHacks
January 12, 2025, 02:02:47 pm

December 2024 Sale! by SMFHacks
December 02, 2024, 10:30:38 pm

Denying members some admin settings by rickk
November 17, 2024, 12:02:55 pm

Weird setup by SMFHacks
November 07, 2024, 06:37:41 am

Restoring a deleted photo by Monocero
November 01, 2024, 04:23:56 am

Gallery Pro reinstalation by Lirorobert
October 14, 2024, 01:43:43 am

Move picture from main gallery to user gallery by SMFHacks
October 11, 2024, 09:11:00 pm

Powered by EzPortal