News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Adding a gallery to custom blocks mod

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

Previous topic - Next topic

Arantor

That is not a publicly accessible board. In fact IIRC you have to be a Friend to be able to see that.

Kindred

DOH!

Hmmm...  I wonder if Markham would mind me posting a copy here.. It's pretty nice slideshow code
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

S Mac

Thanks vbgamer45...I couldn't ask u to write a code, I don't have any $$. But Kindred's reply looks promising. But er, what's a simple image per load? I want quite a small gallery to slot into the top of my forum. Just a simple slideshow type thing.

Kindred

look here: http://www.askawitchcommunity.org/
over in the right column is a single image from the gallery.
It is loaded once per page load... there is no "slideshow" but it picks a random image each page load.

On the other hand at one point - I had an actual streaming slideshow, loading and scrolling through 30 images -- one image every 3 seconds.


The first script is simple - and is listed is the avea support thread (with several variations)
the second script is complicated (and can be resource intensive) and is on the wedge page that I linked to (which as Arantor reminded me, is not visible to standard guests or even general users)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

S Mac

Ah, great. Thanks for that. Unfortunately I'm kinda leaning towards the gallery. It'd be ideal as the forum should be fairly picture-led. But d'you think it'll slow my web page too much?

Kindred

it's a possibility....   It was a known issue on the site that I ran it on (which was running on a dedicated server)
but then again, we had a huge gallery and hundreds of people online at any one time.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

S Mac

I certainly won't have that problem, at least not for a while :( So who do I have to suck up to, to get this code? This Markham fella/girl?

Kindred

possibly.

He posted it in the semi-private area over on Wedge.    I have sent him a PM there asking if I can pass on the file(s) here...  but it may take a while to get an answer. He has not been online for a month and a half.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

S Mac

Appreciate that. I'll wait to see if he gets back to us. Thanks for your help.

S Mac

OK, I couldn't wait. I'm going to try the simple version...but I can't find the script I need over on the Mod support page (for the single-load thing). Could you help pls? And also, where & how do I input the script when I have it? Thanks

Kindred

This is what I use in one of my portal blocks...

the first bit, which is commented out would probably also work by itself...


//global $sourcedir, $user_info, $ID_MEMBER, $context, $txt, $galurl, $galurl2, $scripturl, $settings, $db_prefix;
//loadLanguage('Aeva');
//@include_once($sourcedir . '/Aeva-Subs.php');
//echo aeva_listItems(aeva_getMediaItems(0, 1, 'RAND()'), false, '', 1);

global $sourcedir, $user_info, $ID_MEMBER, $context, $txt, $galurl, $galurl2, $scripturl, $settings, $db_prefix;

echo '
<div class="img_gallery" style="width:40%;overflow:none;float:left;">';

   require_once($sourcedir . '/Aeva-Subs.php');
//   loadMGal_Settings();
   loadLanguage('Aeva', 'english');

// Random=1 or Latest = 0
      $blocktype = 1;

// "thumb" or "preview"
      $blockimagetype = 'preview';

//      $blockFolder = $boarddir . '/Themes/default/aeva';
//      $blockItemsFile = $scrollerFolder . '/imageScrollerItems.xml';

// How many pictures
      $blockMaxItems = 1;
      $blockoffset = 0;
// width of block in percent
      $boxwidth = 100;
//img width
      $imgwidth = '175px';

if ($blocktype = 1 ) {
//Random
$items = aeva_getMediaItems($blockoffset, $blockMaxItems, 'rand()', true, array());
//, 'm.type = "image" AND a.access LIKE "%-1%" AND a.passwd=""');
} else {
//Latest
$items = aeva_getMediaItems($blockoffset, $blockMaxItems, 'm.id_media DESC', true, array());
}

echo '
    <div style="align: center;">';
echo '
        <div class="smalltext" style="text-align: center; margin-left: auto ;  margin-right: auto ;"></div>';

   foreach($items as $item) {
      echo '
   <div class="smalltext" style="display: inline; padding: 5px;float:left;text-align:center; align:center;  margin-left: auto;  margin-right: auto;">
      <h2><a href="',$galurl,'sa=item;id=',$item['id'],'">',$item['title'],'</a></h2><br />
      <a href="',$galurl,'sa=media;id=',$item['id'],'" title="',$item['title'],'" class="hs  " onclick="return hs.expand(this);"><img alt="" src="',$galurl,'sa=media;id=',$item['id'],';',$blockimagetype,'" alt=""  style="max-width:',$imgwidth,';" /></a><br />
      ',$txt['aeva_views'],' : ',$item['views'],'<br />
      ',$txt['aeva_posted_by'],' : <a href="',$scripturl,'?action=profile;u=',$item['poster_id'],'">',$item['poster_name'],'</a><br />
      ',$txt['aeva_in_album'],' : <a href="',$galurl,'sa=album;id=',$item['id_album'],'">',$item['album_name'],'</a>
      ',$item['is_new'] ? '<br /><img alt="" src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" border="0" />' : '','
    </div>';
    }
echo '
<br style="clear:both;" />
</div>';
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

S Mac

Wow. That looks scary. Where do I stick it, so to speak :)

S Mac

Oh, sorry. Do I just stick it in the block? Sorry to be dumb, it's a curse!

Kindred

yup....

do note some of the arguments and defined variables to make it do different things -- everything is pretty well commented.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

S Mac

I've decided to have another go at adding a gallery... I think I'm going to try the SMF Gallery because it's the most up-to-date. Will this code still work in the block to make the pictures refresh on page load?

Kindred

no. the code that I gave is specific to aeva
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

S Mac

Oh. I'm just a bit nervous about installing the Aeva coz I don't have a clue - obviously - so if something went wrong I'm stuffed. Is there any way to get the SMF one into the block with the page load refresh thing?

vbgamer45

Are you just wanting to display random gallery items if so I can write SMF Gallery code for that  not too hard
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

Yes, I want to add a gallery  (SMF Gallery) of maybe four pictures in a row to my header block. Ideally the pics would change on each page load. Does this make sense/is it possible? And if so...you'd do that in return for my extreme gratitude/goodwill?

vbgamer45

Here is the code for SMF 2.0.x


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;


$galleryPro = true;





// 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

Advertisement: