Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4253
Latest: Ineedsmfhelp
New This Month: 1
New This Week: 0
New Today: 0
Stats
Total Posts: 43242
Total Topics: 7516
Most Online Today: 118
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 108
Total: 108

Author Topic: How to show recent images from gallery on external page?  (Read 21972 times)

0 Members and 1 Guest are viewing this topic.

Offline vmustang

  • Member
  • *
  • Posts: 1
    • View Profile
How to show recent images from gallery on external page?
« on: November 27, 2011, 04:22:26 pm »
How do I do this?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16428
    • View Profile
Re: How to show recent images from gallery on external page?
« Reply #1 on: November 28, 2011, 11:26:28 am »
We can do this though SSI would kind of information do you want to show I can write a  quick code to do so.
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 SkyWarn UK

  • Member
  • *
  • Posts: 1
    • View Profile
Re: How to show recent images from gallery on external page?
« Reply #2 on: November 30, 2011, 01:52:56 pm »
I would love to know how to do this too... i would like to display a row of 3 or 4 random images from within SMF Gallery Lite on an external, non-forum webpage. Any help would be great!

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16428
    • View Profile
Re: How to show recent images from gallery on external page?
« Reply #3 on: November 30, 2011, 07:58:12 pm »
What SMF version do you need?
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 sprange

  • Member
  • *
  • Posts: 7
    • View Profile
Re: How to show recent images from gallery on external page?
« Reply #4 on: March 11, 2014, 02:48:53 pm »
Hello - I realize this is an old post, but I am looking for the same solution.

i would like to display a row of 7 or 8 random images from within SMF Gallery Lite on an external, non-forum webpage.  You mentioned that this could be done through SSI? I am using SMF 2.0.7. Thank you for your help.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16428
    • View Profile
Re: How to show recent images from gallery on external page?
« Reply #5 on: March 11, 2014, 02:59:04 pm »
I gave this code recently
Code: [Select]
require 'SSI.php';

SMFGalleryEzBlockGalleryBlock(4,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;

}
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 sprange

  • Member
  • *
  • Posts: 7
    • View Profile
Re: How to show recent images from gallery on external page?
« Reply #6 on: March 12, 2014, 03:24:26 pm »
Thank you. Would the same code work for SMF version 1.1.4? I am trying to get this to work on a test server prior to completing my upgrade.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16428
    • View Profile
Re: How to show recent images from gallery on external page?
« Reply #7 on: March 12, 2014, 03:55:39 pm »
No SMF 2.0.x

But you can grab the similiar code from ezportal for 1.1.0x and it would work.
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 sprange

  • Member
  • *
  • Posts: 7
    • View Profile
Re: How to show recent images from gallery on external page?
« Reply #8 on: March 19, 2014, 06:47:27 am »
I am attempting to add the random images box to a Wordpress site and it seems as though WP has a variable conflict with SMF. I am able to get the block to show using EzPortal within the forum, however when I add the code to my WP homepage, it breaks the page. Do you know of a way to add the random image block within using the ssi.php $variable? I am using SMF 1.1.19. Thank you in advance for your help.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16428
    • View Profile
Re: How to show recent images from gallery on external page?
« Reply #9 on: March 19, 2014, 08:06:10 am »
Well w hat I would do is make is make another php file with ssi and include the random picture code.

Then use an iframe html code to link to that page from wordpress
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 sprange

  • Member
  • *
  • Posts: 7
    • View Profile
Re: How to show recent images from gallery on external page?
« Reply #10 on: March 19, 2014, 08:52:57 pm »
Thank you for your help. I think the iframe method will work. I am able to load the ssi.php file on this new php page. I'm having issues pulling the correct code for SMF 1.1.19. If I view source directly from a forum page, it shows the generated static source. Where would I pull the dynamic code from eZPortal?

Code: [Select]
<table style="margin: 0 auto;"  width="100%">
<tr><td width="100%" valign="top" align="center"  id="column5" >
      <table class="bordercolor" width="100%"><tr>
<td class="catbg">SMF Gallery Random Image <a href="http://www.jeepthing.org/forum/index.php?action=ezportal;sa=editblock;block=8"><img src="http://www.jeepthing.org/forum/ezportal/icons/page_white_edit.png" alt="Edit" /></a>
&nbsp;
<a href="http://www.jeepthing.org/forum/index.php?action=ezportal;sa=deleteblock;block=8"><img src="http://www.jeepthing.org/forum/ezportal/icons/plugin_delete.png" alt="Delete" /></a></td>
</tr>
<tr class="windowbg2"><td id="block8" ><table align="center">
<tr><td align="center"><a href="http://www.jeepthing.org/forum/index.php?action=gallery;sa=view;id=2"><img src="http://www.jeepthing.org/forum/gallery/thumb_3723_17_03_14_7_15_54.jpeg" alt="" /></a></td></tr>

</table></td>
</tr></table>
</td></tr>
</table>

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16428
    • View Profile
Re: How to show recent images from gallery on external page?
« Reply #11 on: March 19, 2014, 11:29:26 pm »
The dynamic is code in Sources/Subs-EzportalMain.php
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 sprange

  • Member
  • *
  • Posts: 7
    • View Profile
Re: How to show recent images from gallery on external page?
« Reply #12 on: March 20, 2014, 10:16:53 pm »
Rather than an iframe, I decided to pull the images using a separate php page and
Code: [Select]
<?php echo file_get_contents('http://www.jeepthing.org/randomimage.php'); ?>
If I put test text in the page, that seems to pull in fine. But the code I got from sources/Subs-EzportalMain.php for the random images doesn't seem to work. I'm not sure what I am doing wrong. I really appreciate your help with this.

Here is the code for my external php page:
Code: [Select]
<?php require("/home5/jeepthin/public_html/forum/SSI.php"); ?><!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>JeepThing</title>
</head>

<body>
<?php 
function EzBlockGalleryRandomImage($paramters = array(), $category 0$numimages 1$startHtml ''$endHtml '')
{
global $txt$db_prefix$context$user_info$modSettings$scripturl$boardurl;

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

if (isset($modSettings['gallery_set_count_child']))
$galleryPro true;

echo $startHtml;

// Set the category
$category = (int) $category;

$numimages = (int)  $numimages;
$rows 4;

// Pass all the parematers
foreach($paramters as $myparam)
{
if ($myparam['parameter_name'] == 'category')
$category = (int) $myparam['data'];
if ($myparam['parameter_name'] == 'images')
$numimages = (int) $myparam['data'];
if ($myparam['parameter_name'] == 'rows')
$rows = (int) $myparam['data'];

}

// Check if gallery is installed
if (!isset($modSettings['gallery_max_filesize']))
{
echo $txt['ezp_gallery_block_noinstall'];
}
else
{
if (empty($modSettings['gallery_url']))
$modSettings['gallery_url'] = $boardurl '/gallery/';

// Load the Gallery language files
if (loadlanguage('Gallery') == false)
loadLanguage('Gallery','english');

$rowlevel 0;
$maxrowlevel $rows;

if ($galleryPro == false)
$request db_query("
SELECT 
thumbfilename, ID_PICTURE, filename 
FROM 
{$db_prefix}gallery_pic 
WHERE " 
. ($category == '' ' AND ID_CAT = ' $category ' ') . " approved = 1 ORDER BY RAND() LIMIT " $numimages__FILE____LINE__);
else 
$request db_query("
SELECT 
p.thumbfilename, p.ID_PICTURE, p.filename 
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 != ' AND p.ID_CAT = ' $category '' ) . "
GROUP by p.ID_PICTURE ORDER BY RAND() LIMIT " 
$numimages__FILE____LINE__);




echo '<table align="center">
'
;
while($row mysql_fetch_assoc($request))
{
if ($rowlevel == 0)
echo '<tr>';
echo'<td align="center"><a href="'$scripturl'?action=gallery;sa=view;id='$row['ID_PICTURE'], '"><img src="',  $modSettings['gallery_url'] . $row['thumbfilename'] ,'" alt="" /></a></td>';

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

}

if($rowlevel !=0)
echo '</tr>';

mysql_free_result($request);
echo '

</table>'
;
}


echo $endHtml;

}
 
?>

</body>
</html>

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16428
    • View Profile
Re: How to show recent images from gallery on external page?
« Reply #13 on: March 20, 2014, 10:34:31 pm »
You need a call statement before the function otherwise it won't do anything.

EzBlockGalleryRandomImage(array(),0,1'');
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 sprange

  • Member
  • *
  • Posts: 7
    • View Profile
Re: How to show recent images from gallery on external page?
« Reply #14 on: March 21, 2014, 07:31:11 am »
I am far from a php expert, so my issue is probably in how I coded it, but the code you provided me is giving me a syntax error:

Code: [Select]
<?php require("/home5/jeepthin/public_html/forum/SSI.php"); ?><!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>JeepThing</title>
</head>

<body>
<?php
EzBlockGalleryRandomImage
(array(),0,1'');?>

<?php
function EzBlockGalleryRandomImage($paramters = array(), $category 0$numimages 1$startHtml ''$endHtml '')
{
global $txt$db_prefix$context$user_info$modSettings$scripturl$boardurl;

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

if (isset($modSettings['gallery_set_count_child']))
$galleryPro true;

echo $startHtml;

// Set the category
$category = (int) $category;

$numimages = (int)  $numimages;
$rows 4;

// Pass all the parematers
foreach($paramters as $myparam)
{
if ($myparam['parameter_name'] == 'category')
$category = (int) $myparam['data'];
if ($myparam['parameter_name'] == 'images')
$numimages = (int) $myparam['data'];
if ($myparam['parameter_name'] == 'rows')
$rows = (int) $myparam['data'];

}

// Check if gallery is installed
if (!isset($modSettings['gallery_max_filesize']))
{
echo $txt['ezp_gallery_block_noinstall'];
}
else
{
if (empty($modSettings['gallery_url']))
$modSettings['gallery_url'] = $boardurl '/gallery/';

// Load the Gallery language files
if (loadlanguage('Gallery') == false)
loadLanguage('Gallery','english');

$rowlevel 0;
$maxrowlevel $rows;

if ($galleryPro == false)
$request db_query("
SELECT 
thumbfilename, ID_PICTURE, filename 
FROM 
{$db_prefix}gallery_pic 
WHERE " 
. ($category == '' ' AND ID_CAT = ' $category ' ') . " approved = 1 ORDER BY RAND() LIMIT " $numimages__FILE____LINE__);
else 
$request db_query("
SELECT 
p.thumbfilename, p.ID_PICTURE, p.filename 
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 != ' AND p.ID_CAT = ' $category '' ) . "
GROUP by p.ID_PICTURE ORDER BY RAND() LIMIT " 
$numimages__FILE____LINE__);




echo '<table align="center">
'
;
while($row mysql_fetch_assoc($request))
{
if ($rowlevel == 0)
echo '<tr>';
echo'<td align="center"><a href="'$scripturl'?action=gallery;sa=view;id='$row['ID_PICTURE'], '"><img src="',  $modSettings['gallery_url'] . $row['thumbfilename'] ,'" alt="" /></a></td>';

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

}

if($rowlevel !=0)
echo '</tr>';

mysql_free_result($request);
echo '

</table>'
;
}


echo $endHtml;

}
?>

</body>
</html>

 

Related Topics

  Subject / Started by Replies Last post
0 Replies
3614 Views
Last post April 10, 2007, 09:17:20 pm
by doctoreast
1 Replies
3471 Views
Last post July 08, 2007, 02:08:43 am
by marcbkk
1 Replies
4168 Views
Last post September 25, 2007, 04:26:40 pm
by SMFHacks
3 Replies
5403 Views
Last post March 13, 2008, 09:04:59 pm
by Weathernut
0 Replies
3395 Views
Last post June 03, 2010, 03:04:50 pm
by trifox

+- Recent Topics

is it possible to add support for odysee.com by SMFHacks
March 13, 2024, 10:53:28 pm

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

User Gallery Feature: move / bulk move images by SMFHacks
January 30, 2024, 05:48:25 pm

In the future it may be for smf 2.1.x? by smithloo
January 30, 2024, 12:55:34 am

Powered by EzPortal