News:

Wondering if this will always be free?  See why free is better.

Main Menu

Adding a gallery to custom blocks mod

Started by S Mac, October 30, 2013, 10:33:17 AM

Previous topic - Next topic

S Mac

You're an absolute star. Thank you very much! But...can someone tell me where I put this code? In the block itself?

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

S Mac

OK, I'm obviously doing something wrong. I suspected I would. I've installed the gallery & added a picture. I added your code to my custom block and nothing happened. Am I doing it all wrong? I've attached what I did...

vbgamer45

Do you have pictures loaded in the gallery?
Also if you are an administrator make sure you check Administrotor in permissions to view the block.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

S Mac

Hmm. I checked everything and yes, I have pictures loaded - 2 of them so far but it should still work, right? One strange thing happened when I was checking the permissions in the block - I ticked the box for the administrator to view the block (only moderator was checked before), and the page wouldn't load. I got a strange 'website under administration' message. I wonder if that's something to do with it. Also, I just cut & pasted your code straight in - I didn't have to convert in any way did I?

vbgamer45

#45
Just retested on my site as SSI and works ok here is the ssi code.
You can try otherwise. Try putting
<?php 

In front of all the code.


require 'SSI.php';

SMFGalleryEzBlockGalleryBlock(1,4);
function SMFGalleryEzBlockGalleryBlock($rows = 4, $images = 4, $category = 0, $type = 'recent', $startHtml = '', $endHtml = '')
{
global $txt, $smcFunc, $user_info, $context, $modSettings, $scripturl, $boardurl;


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

// Html Header
echo $startHtml;
$maxrowlevel = $rows;

if ($galleryPro == false)
$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
FROM {db_prefix}gallery_pic as p
LEFT JOIN {db_prefix}members AS m ON (p.ID_MEMBER = m.ID_MEMBER) 
WHERE p.approved = 1 " . ($category != 0 ? ' p.ID_CAT = ' . $category : '' ) . "
ORDER BY p.ID_PICTURE DESC LIMIT $images");
else
$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
FROM {db_prefix}gallery_pic as p
LEFT JOIN {db_prefix}members AS m ON (p.ID_MEMBER = m.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))
" . ($category != 0 ? ' AND p.ID_CAT = ' . $category : '' ) . "
GROUP by p.ID_PICTURE ORDER BY p.ID_PICTURE DESC LIMIT $images");


$gallery_recent = array();
while($row = $smcFunc['db_fetch_assoc']($dbresult))
{
$gallery_recent[] = array(
'ID_PICTURE' => $row['ID_PICTURE'],
'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' => ' <a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">'  . $row['real_name'] . '</a><br />',
);

}
$smcFunc['db_free_result']($dbresult);


//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="100%">
';
$rowlevel = 0;

foreach ($gallery_recent as $picture)
{
if ($rowlevel == 0)
echo '<tr>';

echo '<td align="center"><a href="' . $scripturl . '?action=gallery;sa=view;' . (empty($modSettings['gallery_thumb_width']) ? 'pic=' : 'id=')  . $picture['ID_PICTURE'] . '"><img alt="" src="' . $modSettings['gallery_url'] . $picture['thumbfilename']  . '" /></a><br />
<span class="smalltext">' . 'Views: ' . $picture['views'] . '<br />';
echo 'Comments:' . $picture['commentlink'];
echo 'By: ' . $picture['profilelink'];
echo '</span></td>';

if($rowlevel < ($maxrowlevel-1))
$rowlevel++;
else
{
echo '</tr>';
$rowlevel = 0;
}
}
if($rowlevel !=0)
echo '</tr>';

echo '</table>';

// Html Footer
echo $endHtml;

}
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

S Mac

Hi, I just tried putting the <?php in front of all the code as you suggested and it's still not working I'm afraid. Problem is, when I try to change the block setting so administrator can view, the whole website goes down & I get a HTTP 500 website under maintenance message...what's going wrong?

S Mac

Still need help with this please. I'm dying to get the gallery up & running...

vbgamer45

Hard to say would it be possible to get an admin login/ftp too?
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

S Mac

You mean so you can access it yourself? I guess so, but my life is in your hands. Not joking. So, how do I give you this info?

vbgamer45

Via pm. You can either make a new account and give access would be best safe way. Then  remove access when we are finished.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

vbgamer45

Was able to get to work with your custom blocks mod appears in your forum's header.
Had to do one tweak to the code above which I updated now.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

S Mac

I know, I'm really pleased - thanks for your help. If I want to change the number of pictures in future, do I just change the line: ($rows = 4, $images = 4, $category = 0, $type = 'recent', $startHtml = '', $endHtml = '')
to the relevant figure?

vbgamer45

You would edit this part of the code

SMFGalleryEzBlockGalleryBlock(1,4);


The number 4 controls how many images
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

S Mac


Advertisement: