SimplePortal

Support => English Support => Topic started by: PADEIRA on November 30, 2010, 01:08:23 PM

Title: Recent Image Attachments
Post by: PADEIRA on November 30, 2010, 01:08:23 PM
good friends ...

I'm battling with the pack of recent images I inserted in my simple portal ...

I want to explain is the following ..

images to appear on I SimplePortal when clicking on the images opens blank page to me only om the picture and I wanted to do click to be directed to the topic where the image is ... it is possible to achieve this?

smf version 1.1.12
SimplePortal 2.3.3 version

thanks
Title: Re: Recent Image Attachments
Post by: AngelinaBelle on November 30, 2010, 02:00:49 PM
If I understand properly
* You see that clicking on a recent image from the block shows you the attached image
* You desire that clickong on a recent image from the block will show you instead the message it was attached to.
 
--------------
This requires customization of PortalBlocks.php. You can see it gets its items from the SSI function ssi_recentAttachments
 
Code: (find) [Select]
$item['file']['image']['link']
Code: (replace) [Select]
$item['topic']['link']
Title: Re: Recent Image Attachments
Post by: PADEIRA on November 30, 2010, 05:27:25 PM
hello friend did alteration to indicate but the images disappear ..... I wanted to keep the images when clicking on them and enter the topic where it is ....
Title: Re: Recent Image Attachments
Post by: AngelinaBelle on November 30, 2010, 06:44:34 PM
Oh!  I forgot that part!
 
There are many things about those images available for you to use.
You can see them in SSI.php, in function ssi_recentAttachments
 
I think you can use $item['topic']['href'] for the href part of the link, and $item['file']['image']['link'] $item['file']['image']['href'] for the source of the image.
 
Enjoy!
 
-----------------------
Edit: fixed typo

 
Title: Re: Recent Image Attachments
Post by: PADEIRA on November 30, 2010, 07:05:22 PM
is not working .... or am I doing something wrong: (

I have so the code ...
Code: [Select]
function sp_attachmentImage($parameters, $id, $return_parameters = false)
{
global $db_prefix, $modSettings, $scripturl, $txt, $settings, $user_info;

$block_parameters = array(
'limit' => 'int',
'direction' => 'select',
'disablePoster' => 'check',
'disableDownloads' => 'check',
'disableLink' => 'check',
);

if ($return_parameters)
return $block_parameters;

$limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
$direction = empty($parameters['direction']) ? 0 : 1;
$type = array('jpg', 'png', 'gif', 'bmp');
$boards = boardsAllowedTo('view_attachments');
$showPoster = empty($parameters['disablePoster']);
$showDownloads = empty($parameters['disableDownloads']);
$showLink = empty($parameters['disableLink']);

if (empty($boards))
{
echo '
', $txt['error_sp_no_attachments_found'];
return;
}
elseif ($boards[0] == 0)
$boards = '';
else
$boards = ' AND m.ID_BOARD IN (' . implode(',', $boards) . ')';

$request = db_query("
SELECT
att.ID_ATTACH, att.ID_MSG, att.filename, IFNULL(att.size, 0) AS filesize, att.downloads, mem.ID_MEMBER,
IFNULL(mem.realName, m.posterName) AS posterName, m.ID_TOPIC, m.subject, t.ID_BOARD, m.posterTime,
att.width, att.height" . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? "" : ", IFNULL(thumb.ID_ATTACH, 0) AS id_thumb, thumb.width AS thumb_width, thumb.height AS thumb_height") . "
FROM {$db_prefix}attachments AS att
INNER JOIN {$db_prefix}messages AS m ON (m.ID_MSG = att.ID_MSG)
INNER JOIN {$db_prefix}topics AS t ON (t.ID_TOPIC = m.ID_TOPIC)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? "" : "
LEFT JOIN {$db_prefix}attachments AS thumb ON (thumb.ID_ATTACH = att.ID_THUMB)") . "
LEFT JOIN {$db_prefix}boards AS b ON (b.ID_BOARD = t.ID_BOARD)
WHERE att.attachmentType = 0
AND att.width != 0
AND $user_info[query_see_board]
$boards
ORDER BY att.ID_ATTACH DESC
LIMIT $limit", __FILE__, __LINE__);
$items = array();
while ($row = mysql_fetch_assoc($request))
{
$filename = preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', htmlspecialchars($row['filename']));

$items[$row['ID_ATTACH']] = array(
'member' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>',
),
'file' => array(
'filename' => $filename,
'filesize' => round($row['filesize'] /1024, 2) . $txt['smf211'],
'downloads' => $row['downloads'],
'href' => $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $row['ID_ATTACH'],
'link' => '<img src="' . $settings['images_url'] . '/icons/clip.gif" alt="" /> <a href="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $row['ID_ATTACH'] . '">' . $filename . '</a>',
'is_image' => !empty($row['width']) && !empty($row['height']) && !empty($modSettings['attachmentShowImages']),
),
'topic' => array(
'id' => $row['ID_TOPIC'],
'subject' => $row['subject'],
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#msg' . $row['ID_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#msg' . $row['ID_MSG'] . '">' . $row['subject'] . '</a>',
'time' => timeformat($row['posterTime']),
),
);

if ($items[$row['ID_ATTACH']]['file']['is_image'])
{
$id_thumb = empty($row['ID_THUMB']) ? $row['ID_ATTACH'] : $row['ID_THUMB'];
$items[$row['ID_ATTACH']]['file']['image'] = array(
'id' => $id_thumb,
'width' => $row['width'],
'height' => $row['height'],
'img' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $row['ID_ATTACH'] . ';image" alt="' . $filename . '" />',
'thumb' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '" />',
'href' => $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $id_thumb . ';image',
'link' => '<a href="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $row['ID_ATTACH'] . ';image"><img src="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '"' . (empty($row['ID_THUMB']) ? ' width="225"' : '') . ' /></a>',
);
}
}
mysql_free_result($request);

if (empty($items))
{
echo '
', $txt['error_sp_no_attachments_found'];
return;
}

$colorids = array();
foreach ($items as $item)
$colorids[] = $item['member']['id'];

if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($items as $k => $p)
{
if (!empty($color_profile[$p['member']['id']]['link']))
$items[$k]['member']['link'] = $color_profile[$p['member']['id']]['link'];
}
}

echo '
<table class="sp_auto_align">', $direction ? '
<tr>' : '';

foreach ($items as $item)
{
  echo !$direction ? '
<tr>' : '', '
<td>
<div class="sp_image smalltext">', ($showLink ? '
<a href="' . $item['topic']['link'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
', $item['file']['image']['link'], '<br />', ($showDownloads ? '
' . $txt['sp-downloadsCount'] . ': ' . $item['file']['downloads'] . '<br />' : ''), ($showPoster ? '
' . $txt['sp-downloadsPoster'] . ': ' . $item['member']['link'] : ''), '
</div>
</td>', !$direction ? '
</tr>' : '';
}

echo $direction ? '
</tr>' : '', '
</table>';
}

Title: Re: Recent Image Attachments
Post by: AngelinaBelle on November 30, 2010, 07:40:17 PM
You don't need to copy code in from SSI.php. Why reinvent what function ssi_recentattachments is already doing?
I only look at it to find out what it sends back to the calling function. That is how I found which elements of $items are available to use in sp_recentAttachments.
 
Perhaps something like the code below (warning: untested)
Code: [Select]
           <div class="sp_image smalltext">', ($showLink ? '
            <a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
            ', <a href=". $item['topic']['href'] . "><img src=" .  $item['topic']['href']. '"></a><br />', ($showDownloads ? '
            ' . $txt['downloads'] . ': ' . $item['file']['downloads'] . '<br />' : ''), ($showPoster ? '
            ' . $txt['posted_by'] . ': ' . $item['member']['link'] : ''), '
           </div>
Title: Re: Recent Image Attachments
Post by: PADEIRA on December 01, 2010, 12:09:08 PM
Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\mig\Sources\PortalBlocks.php on line 1681 :(
Title: Re: Recent Image Attachments
Post by: AngelinaBelle on December 01, 2010, 12:48:21 PM
You really have to squint to spot these.  That's why the line numbers are so useful.
Code: (find) [Select]
           <div class="sp_image smalltext">', ($showLink ? '
            <a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
            ', $item['file']['image']['link'], '<br />', ($showDownloads ? '
Code: (replace) [Select]
           <div class="sp_image smalltext">', ($showLink ? '
            <a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
            ', '<a href="' . $item['topic']['href'] . '"><img src="' .  $item['topic']['href']. ''"></a><br />', ($showDownloads ? '

 
Again -- untested.  I leave the remaining testing as an exercise for the reader.
Title: Re: Recent Image Attachments
Post by: PADEIRA on December 01, 2010, 01:11:10 PM
Good AngelinaBelle

yes I have found the code without problems ..... I have made the changes but now the images do not appear ....
Title: Re: Recent Image Attachments
Post by: AngelinaBelle on December 01, 2010, 01:56:56 PM
I am trying to go to fast.  Of course, where I have put
Code: [Select]
<img src="' .  $item['topic']['href']. ''"> it should be
Code: [Select]
<img src="' .  $item['file']['image']['href']. ''">
Or, perhaps even
Code: [Select]
$item['file']['image']['img']
You should experiment with this different things and see which you like best.
Title: Re: Recent Image Attachments
Post by: PADEIRA on December 01, 2010, 02:12:55 PM
Hello AngelinaBelle

with this code
Code: [Select]
$item['file']['image']['img']
worked ... appeared the image and directs me to the topic where it is now but another headache .... the image appeared to me the actual size of these images in the block in the block that was reduced to 225
Title: Re: Recent Image Attachments
Post by: AngelinaBelle on December 01, 2010, 11:40:15 PM
Do you have portal image resizing turned on?
Or would you prefer to use the thumbnail size image?
Code: [Select]
<img src="' .  $item['file']['image']['thumb']. ''">
There are so many possiblities.
Title: Re: Recent Image Attachments
Post by: PADEIRA on December 02, 2010, 09:27:16 AM
hello AngelinaBelle

I have images in the portal code scaled well as presents the code below ...

Code: [Select]
      if ($items[$row['ID_ATTACH']]['file']['is_image'])
      {
         $id_thumb = empty($row['ID_THUMB']) ? $row['ID_ATTACH'] : $row['ID_THUMB'];
         $items[$row['ID_ATTACH']]['file']['image'] = array(
            'id' => $id_thumb,
            'width' => $row['width'],
            'height' => $row['height'],
            'img' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $row['ID_ATTACH'] . ';image" alt="' . $filename . '" />',
            'thumb' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '" />',
            'href' => $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $id_thumb . ';image',
            'link' => '<a href="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $row['ID_ATTACH'] . ';image"><img src="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '"' . (empty($row['ID_THUMB']) ? ' width="225"' : '') . ' /></a>',
         );


the problem is that the alterations made to me they appear normal in size .... and not as it is configured in the portal code ....
Title: Re: Recent Image Attachments
Post by: AngelinaBelle on December 02, 2010, 03:53:41 PM
Let's go back to the beginning.  Please start with a fresh copy of PortalBlocks.php.
Do not add any code from SSI.php. Only use what the function ssi_recentAttachments provides to you.
Code: (find in portalblocks.php) [Select]
$item['file']['image']['link']
Code: (replace in portalblocks.php) [Select]
'<a href="',  $item['topic']['href'],  '"><img src="', $item['file']['image']['thumb'],  '"></a>'
You can just LOOK in ssi_recentAttachments to see what it is putting into each of those array elements.
Title: Re: Recent Image Attachments
Post by: PADEIRA on December 02, 2010, 05:26:31 PM
ello friend ...
I have done as thou hast commanded but something is wrong ....

I'll send you my files portalblocks.php you to confirm if you please ....
Ouvir
Ler foneticamente
Title: Re: Recent Image Attachments
Post by: AngelinaBelle on December 02, 2010, 08:13:42 PM
Code: [Select]
function sp_attachmentImage($parameters, $id, $return_parameters = false)
{
 global $boarddir, $txt, $color_profile;
 $block_parameters = array(
  'limit' => 'int',
  'direction' => 'select',
  'disablePoster' => 'check',
  'disableDownloads' => 'check',
  'disableLink' => 'check',
 );
 if ($return_parameters)
  return $block_parameters;
 $limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
 $direction = empty($parameters['direction']) ? 0 : 1;
 $type = array('jpg', 'png', 'gif', 'bmp');
 $showPoster = empty($parameters['disablePoster']);
 $showDownloads = empty($parameters['disableDownloads']);
 $showLink = empty($parameters['disableLink']);
 $items = ssi_recentAttachments($limit, $type, 'array');
 if (empty($items))
 {
  echo '
        ', $txt['error_sp_no_attachments_found'];
  return;
 }
 $colorids = array();
 foreach ($items as $item)
  $colorids[] = $item['member']['id'];
 if (!empty($colorids) && sp_loadColors($colorids) !== false)
 {
  foreach ($items as $k => $p)
  {
   if (!empty($color_profile[$p['member']['id']]['link']))
    $items[$k]['member']['link'] = $color_profile[$p['member']['id']]['link'];
  }
 }
 echo '
        <table class="sp_auto_align">', $direction ? '
         <tr>' : '';
 foreach ($items as $item)
 {
   echo !$direction ? '
         <tr>' : '', '
          <td>
           <div class="sp_image smalltext">', ($showLink ? '
            <a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
            ', <a href="',  $item['topic']['href'],  '"><img src="', $item['file']['image']['thumb'],  '"></a>,  // the change is in this line.
            '<br />', ($showDownloads ? '
            ' . $txt['downloads'] . ': ' . $item['file']['downloads'] . '<br />' : ''), ($showPoster ? '
            ' . $txt['posted_by'] . ': ' . $item['member']['link'] : ''), '
           </div>
          </td>', !$direction ? '
         </tr>' : '';
 }
 echo $direction ? '
         </tr>' : '', '
        </table>';
}

Title: Re: Recent Image Attachments
Post by: PADEIRA on December 03, 2010, 12:18:51 PM
Code: [Select]
function sp_attachmentImage($parameters, $id, $return_parameters = false)
{
 global $boarddir, $txt, $color_profile;
 $block_parameters = array(
  'limit' => 'int',
  'direction' => 'select',
  'disablePoster' => 'check',
  'disableDownloads' => 'check',
  'disableLink' => 'check',
 );
 if ($return_parameters)
  return $block_parameters;
 $limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
 $direction = empty($parameters['direction']) ? 0 : 1;
 $type = array('jpg', 'png', 'gif', 'bmp');
 $showPoster = empty($parameters['disablePoster']);
 $showDownloads = empty($parameters['disableDownloads']);
 $showLink = empty($parameters['disableLink']);
 $items = ssi_recentAttachments($limit, $type, 'array');
 if (empty($items))
 {
  echo '
        ', $txt['error_sp_no_attachments_found'];
  return;
 }
 $colorids = array();
 foreach ($items as $item)
  $colorids[] = $item['member']['id'];
 if (!empty($colorids) && sp_loadColors($colorids) !== false)
 {
  foreach ($items as $k => $p)
  {
   if (!empty($color_profile[$p['member']['id']]['link']))
    $items[$k]['member']['link'] = $color_profile[$p['member']['id']]['link'];
  }
 }
 echo '
        <table class="sp_auto_align">', $direction ? '
         <tr>' : '';
 foreach ($items as $item)
 {
   echo !$direction ? '
         <tr>' : '', '
          <td>
           <div class="sp_image smalltext">', ($showLink ? '
            <a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
            ', <a href="',  $item['topic']['href'],  '"><img src="', $item['file']['image']['thumb'],  '"></a>,  // the change is in this line.
            '<br />', ($showDownloads ? '
            ' . $txt['downloads'] . ': ' . $item['file']['downloads'] . '<br />' : ''), ($showPoster ? '
            ' . $txt['posted_by'] . ': ' . $item['member']['link'] : ''), '
           </div>
          </td>', !$direction ? '
         </tr>' : '';
 }
 echo $direction ? '
         </tr>' : '', '
        </table>';
}


Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\mig\Sources\PortalBlocks.php on line 1601
Title: Re: Recent Image Attachments
Post by: AngelinaBelle on December 03, 2010, 05:05:19 PM
Code: [Select]
function sp_attachmentImage($parameters, $id, $return_parameters = false)
{
 global $boarddir, $txt, $color_profile;
 $block_parameters = array(
  'limit' => 'int',
  'direction' => 'select',
  'disablePoster' => 'check',
  'disableDownloads' => 'check',
  'disableLink' => 'check',
 );
 if ($return_parameters)
  return $block_parameters;
 $limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
 $direction = empty($parameters['direction']) ? 0 : 1;
 $type = array('jpg', 'png', 'gif', 'bmp');
 $showPoster = empty($parameters['disablePoster']);
 $showDownloads = empty($parameters['disableDownloads']);
 $showLink = empty($parameters['disableLink']);
 $items = ssi_recentAttachments($limit, $type, 'array');
 if (empty($items))
 {
  echo '
        ', $txt['error_sp_no_attachments_found'];
  return;
 }
 $colorids = array();
 foreach ($items as $item)
  $colorids[] = $item['member']['id'];
 if (!empty($colorids) && sp_loadColors($colorids) !== false)
 {
  foreach ($items as $k => $p)
  {
   if (!empty($color_profile[$p['member']['id']]['link']))
    $items[$k]['member']['link'] = $color_profile[$p['member']['id']]['link'];
  }
 }
 echo '
        <table class="sp_auto_align">', $direction ? '
         <tr>' : '';
 foreach ($items as $item)
 {
   echo !$direction ? '
         <tr>' : '', '
          <td>
           <div class="sp_image smalltext">', ($showLink ? '
            <a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
            <a href="',  $item['topic']['href'],  '"><img src="', $item['file']['image']['thumb'],  '"></a>,  // the change is in this line.
            '<br />', ($showDownloads ? '
            ' . $txt['downloads'] . ': ' . $item['file']['downloads'] . '<br />' : ''), ($showPoster ? '
            ' . $txt['posted_by'] . ': ' . $item['member']['link'] : ''), '
           </div>
          </td>', !$direction ? '
         </tr>' : '';
 }
 echo $direction ? '
         </tr>' : '', '
        </table>';
}

Title: Re: Recent Image Attachments
Post by: Chas on December 13, 2012, 02:33:32 PM
Sorry to reopen an old topic but I need to do the same thing, essentially click the image(s) on the block takes the user to the topic where the image is posted.

Have tried applying Angelina's mods as above but they result in white screens. Can anyone provide full code changes for 2.3.5 codebase to enable this feature.

No guests have access only members.

Thanks

Chas.
Title: Re: Recent Image Attachments
Post by: AngelinaBelle on January 05, 2013, 05:04:46 PM
I am not quite certain why this failed, and have not had time to test.
Have you looked at the HTML for that page to see where it has gone wrong?

Perhaps it would be best to abandon that supplied subroutine, and go back to the general idea
Code: (find in portalblocks.php) [Select]
$item['file']['image']['link']
Code: (replace in portalblocks.php) [Select]
'<a href="',  $item['topic']['href'],  '"><img src="', $item['file']['image']['thumb'],  '"></a>'

It seems to me this should still work, even if there are errors in the subroutine I supplied.

My apologies for supplying bad code.
Title: Re: Recent Image Attachments
Post by: velorooms on January 05, 2013, 07:58:54 PM
Here is the code from my sources/portalblocks.php

from the start of attachment image, to the start of the next block.

Code: [Select]
function sp_attachmentImage($parameters, $id, $return_parameters = false)
{
global $boarddir, $txt, $color_profile;

$block_parameters = array(
'limit' => 'int',
'direction' => 'select',
'disablePoster' => 'check',
'disableDownloads' => 'check',
'disableLink' => 'check',
);

if ($return_parameters)
return $block_parameters;

$limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
$direction = empty($parameters['direction']) ? 0 : 1;
$type = array('jpg', 'png', 'gif', 'bmp');
$showPoster = empty($parameters['disablePoster']);
$showDownloads = empty($parameters['disableDownloads']);
$showLink = empty($parameters['disableLink']);

$items = ssi_recentAttachments($limit, $type, 'array');

if (empty($items))
{
echo '
', $txt['error_sp_no_attachments_found'];
return;
}

$colorids = array();
foreach ($items as $item)
$colorids[] = $item['member']['id'];

if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($items as $k => $p)
{
if (!empty($color_profile[$p['member']['id']]['link']))
$items[$k]['member']['link'] = $color_profile[$p['member']['id']]['link'];
}
}

echo '
<table class="sp_auto_align">', $direction ? '
<tr>' : '';

foreach ($items as $item)
{
  echo !$direction ? '
<tr>' : '', '
<td>
<div class="sp_image smalltext">', ($showLink ? '
<a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
<a href="' . $item['topic']['href'] . '">', $item['file']['image']['thumb'], '</a> <br />', ($showDownloads ? '
' . $txt['downloads'] . ': ' . $item['file']['downloads'] . '<br />' : ''), ($showPoster ? '
' . $txt['posted_by'] . ': ' . $item['member']['link'] : ''), '
</div>
</td>', !$direction ? '
</tr>' : '';
}

echo $direction ? '
</tr>' : '', '
</table>';
}

function sp_attachmentRecent($parameters, $id, $return_parameters = false)

Havnt looked in depth at what we changed, but that does exactly what it should, if you click on the image you are taken to the post in question.

You can view it live on the myhomepage.
Title: Re: Recent Image Attachments
Post by: Chas on January 06, 2013, 01:44:55 AM
I am not quite certain why this failed, and have not had time to test.
Have you looked at the HTML for that page to see where it has gone wrong?

Perhaps it would be best to abandon that supplied subroutine, and go back to the general idea
Code: (find in portalblocks.php) [Select]
$item['file']['image']['link']
Code: (replace in portalblocks.php) [Select]
'<a href="',  $item['topic']['href'],  '"><img src="', $item['file']['image']['thumb'],  '"></a>'

It seems to me this should still work, even if there are errors in the subroutine I supplied.

My apologies for supplying bad code.
This removes the images from the block and replaces them with links to the topic, is that what you intended?
Title: Re: Recent Image Attachments
Post by: AngelinaBelle on January 07, 2013, 04:46:16 PM
$item['file']['image']['thumb'] is the image that is shown.
Indeed, the link is to the topic.

That was the request from the OP -- to show the image, but link to the topic.

What would you like to show, and link to?
Title: Re: Recent Image Attachments
Post by: Chas on January 07, 2013, 04:49:51 PM
$item['file']['image']['thumb'] is the image that is shown.
Indeed, the link is to the topic.

That was the request from the OP -- to show the image, but link to the topic.

What would you like to show, and link to?
As the purpose of the module is to show the image I would like it to remain so but the image to be linked to the topic.
Thanks.
Title: Re: Recent Image Attachments
Post by: velorooms on January 07, 2013, 05:19:14 PM
I posted my code two posts up. If look on my portal and click the recent images pictures (left hand side down a bit), they do exactly that, take you to the post in question.

And im using the code i posted. (unless there is more code i have changed somewhere else :S)
Title: Re: Recent Image Attachments
Post by: Chas on January 07, 2013, 05:23:37 PM
Thanks Velorooms, I had tried your code and just got white pages.

Any chance you can post your portalblocks.php file so I can do a side by side comparison? Or even just use yours?

Thanks.
Title: Re: Recent Image Attachments
Post by: velorooms on January 07, 2013, 06:07:38 PM
mine are attached for both 2.3.4 and 2.3.5

worth noting i have made some other adjustments to portal blocks to change a  few things. If you need to view differences try using examdiff which is a really good text file comparer.

I am wondering if i made a change somewhere other than in portalblocks.php I know it took me a while to figure it out. I really need to keep records. :S

DONT use my php file though. its heavily modified, for instance i have png post icons rather than gifs, theres a fair few non standard bits in there. Will mess things up. Ive isolated the line in the post below.
Title: Re: Recent Image Attachments
Post by: velorooms on January 07, 2013, 06:15:12 PM
Just looking through myself.

2.3.5 Portalblocks.php has this line

Code: [Select]
<a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
', $item['file']['image']['link'], '<br />', ($showDownloads ? '


I have

Code: [Select]
<a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
<a href="' . $item['topic']['href'] . '">', $item['file']['image']['thumb'], '</a> <br />', ($showDownloads ? '

what i appear to have done is surround the image thumb with a href linking to the topic

<a href="' . $item['topic']['href'] . '" 

Before the second line of code

and </a>  before the <br>

basically surrounded the thumbnail by a href.. i just need to work out if i specified 'topic' elsewhere in the file.
Title: Re: Recent Image Attachments
Post by: Chas on January 08, 2013, 01:13:31 AM
Just looking through myself.

2.3.5 Portalblocks.php has this line

Code: [Select]
<a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
', $item['file']['image']['link'], '<br />', ($showDownloads ? '


I have

Code: [Select]
<a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
<a href="' . $item['topic']['href'] . '">', $item['file']['image']['thumb'], '</a> <br />', ($showDownloads ? '

what i appear to have done is surround the image thumb with a href linking to the topic

<a href="' . $item['topic']['href'] . '" 

Before the second line of code

and </a>  before the <br>

basically surrounded the thumbnail by a href.. i just need to work out if i specified 'topic' elsewhere in the file.
Yes, that did the trick and was all that was needed to make the images in the block linked to the topic, exactly what I needed. many thanks.
Regards
Chas.
Title: Re: Recent Image Attachments
Post by: AngelinaBelle on January 14, 2013, 08:20:22 PM
Congratulations, you two! Chas, I'm glad you got it exactly the way you wanted it.
SimplePortal 2.3.8 © 2008-2024, SimplePortal