Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4255
Latest: andreios
New This Month: 3
New This Week: 1
New Today: 0
Stats
Total Posts: 43259
Total Topics: 7518
Most Online Today: 201
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 187
Total: 187

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

+- Recent Topics

No thumbnails on new uploads by SMFHacks
March 27, 2024, 02:10:41 pm

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

an idea for new mod (( content type with different display )) by SMFHacks
February 27, 2024, 01:36:27 pm

[Mod] RSS Feed Poster by SMFHacks
February 27, 2024, 11:57:18 am

find duplicate pictures by fvlog19
February 14, 2024, 02:22:40 pm

Error uploading video. by SMFHacks
February 08, 2024, 02:04:16 pm

Gallery icon as last added image by fvlog19
February 01, 2024, 01:04:56 pm

Powered by EzPortal