Advertisement:

Author Topic: Need help on Simple portal Board news code for image resizing  (Read 6512 times)

Offline drfun

  • Jr. Member
  • **
  • Posts: 185
  • Gender: Male
    • All Student Forum
Hello all,
I have been trying to modify my old sp block code to the current code for the board news. This initial old code was working well on my forum but stoped after i upgraded to smf 2.0.13. The old code was meant to resize images on the Simple Portal board news and to also give the images boarders. Below is the old code i was using in my source/portalblocks.php
Code: [Select]
if ($context['SPortal']['core_compat'])
   {
      foreach ($return as $news)
      {
         echo '
               <div class="tborder sp_article_content">
                  <table class="sp_block">
                     <tr class="catbg">
                        <td class="sp_middle">', $news['icon'], '</td>
                        <td class="sp_middle sp_regular_padding sp_fullwidth"><a href="', $news['href'], '" >', $news['subject'], '</a></td>
                     </tr>
                     <tr class="roundframe">
                        <td class="sp_regular_padding" colspan="2">';

         if ($avatars && $news['avatar']['name'] !== null && !empty($news['avatar']['href']))
            echo '
                           <a href="', $scripturl, '?action=profile;u=', $news['poster']['id'], '"><img src="', $news['avatar']['href'], '" alt="', $news['poster']['name'], '" width="30" height="30" style="float: right;" /></a><br />
                           <div class="middletext">', $news['time'], ' | ', $txt['by'], ' ', $news['poster']['link'], '</div>';
         else
            echo '
                           <div class="middletext">', $news['time'], ' ', $txt['by'], ' ', $news['poster']['link'], '</div>';

   
                  echo '               
                           <div class="post"><hr /><div class="haberblog">', $news['body'], '<br /><br /></div></div>
                        </td>
                     </tr>
                     <tr>
                        <td class="windowbg2" colspan="2"><hr />
                             <div class="yorumbuton">
                       <div class="yorum">', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div><div class="buton">', $news['link'], ' ',  $news['new_comment'], '</div></div>
                        </td>
                     </tr>
                  </table>
               </div>';
      }
   }
   else
   {
      foreach ($return as $news)
      {
         echo '
               <div class="cat_bar">
                  <h3 class="catbg">
                     <span class="sp_float_left sp_article_icon">', $news['icon'], '</span><a href="', $news['href'], '" >', $news['subject'], '</a>
                  </h3>
               </div>
               <div class="windowbg sp_article_content">
                  <span class="topslice"><span></span></span>
                  <div class="sp_content_padding">';

         if ($avatars && $news['avatar']['name'] !== null && !empty($news['avatar']['href']))
            echo '
                     <a href="', $scripturl, '?action=profile;u=', $news['poster']['id'], '"><img src="', $news['avatar']['href'], '" alt="', $news['poster']['name'], '" width="30" height="30" class="sp_float_right" /></a><br />
                     <div class="middletext">', $news['time'], ' | ', $txt['by'], ' ', $news['poster']['link'], '</div>';
         else
            echo '
                     <div class="middletext">', $news['time'], ' ', $txt['by'], ' ', $news['poster']['link'], '</div>';

         echo '
                     <div class="post"><hr /><div class="haberblog">', $news['body'], '</div></div><hr />
                       <div class="yorumbuton">
                       <div class="yorum">', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div><div class="buton">', $news['link'], ' ',  $news['new_comment'], '</div></div>
                  </div>
                  <span class="botslice"><span></span></span>
               </div>';
      }   
   }
   if (!empty($modSettings['articleperpage']) && !empty($context['page_index']))
      echo '
               <div class="sp_page_index">', $txt['sp-articlesPages'], ': ', $page_index, '</div>';
}

and also this CSS code in my portal.css

Code: [Select]
.haberblog {
   
   overflow: auto;
    margin-top: -16px;
}
.haberblog  img
{
   border: 1px solid #5998A7;
   border-radius: 3px;
   -moz-border-radius: 3px;
   margin: 16px 10px 0px 10px;
   -webkit-border-radius: 3px;
    padding: 6px 6px 6px 6px;
    width: 142px;
    height: 85px;
}
.haberblog  li a img
{

   border-radius: 3px;
    width: 142px;
    height: 85px;
}
.yorumbuton
{
   border: 0px solid #5998A7;
   width: 100%;

   overflow: auto;

}
.yorum
{
   border-right: 0px solid #5998A7;
   width: 50%;
   float: left;
    overflow: auto;
    padding: 5px 10px 10px 10px;
}
.buton
{
   border: 0px solid #5998A7;
float: right;
overflow: auto;

cursor: pointer;
padding: 5px 10px 10px 10px;
background: #f7f7f7;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f7f7), color-stop(100%,#f7f7f7));
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#f7f7f7',GradientType=0 );
border-radius: 5px;
}

However everything was working well the way it was meant to until i upgraded to smf 2.0.13, so i tried to work with the new code bellow, which i did some editing but i am not get it to resize the images on the board news or for it to work well as it was before. I also notice on my 2nd forum running on 2.0.12, the old code works well.

 Below is the new code i modified.


Code: [Select]
if ($context['SPortal']['core_compat'])
{
foreach ($return as $news)
{
echo '
<div class="sp_article_content">
<div class="', !empty($style['no_body']) ? '' : ' tborder', '">
<table class="sp_block">';

if (empty($style['no_title']))
{
echo '
<tr>
<td class="sp_middle ', $style['title']['class'], '"', !empty($style['title']['style']) ? ' style="' . $style['title']['style'] . '"' : '', '>', $news['icon'], '</td>
<td class="sp_middle sp_regular_padding sp_fullwidth ', $style['title']['class'], '"', !empty($style['title']['style']) ? ' style="' . $style['title']['style'] . '"' : '', '><a href="', $news['href'], '">', $news['subject'], '</a></td>
</tr>';
}

echo '
<tr>
<td class="sp_block_padding', empty($style['body']['class']) ? '' : ' ' . $style['body']['class'], '"', !empty($style['body']['style']) ? ' style="' . $style['body']['style'] . '"' : '', ' colspan="2">';

if ($avatars && $news['avatar']['name'] !== null && !empty($news['avatar']['href']))
echo '
<a href="', $scripturl, '?action=profile;u=', $news['poster']['id'], '"><img src="', $news['avatar']['href'], '" alt="', $news['poster']['name'], '" width="30" style="float: right;" /></a>
<div class="middletext">', $news['time'], ' ', $txt['by'], ' ', $news['poster']['link'], '<br />', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div>';
else
echo '
<div class="middletext">', $news['time'], ' ', $txt['by'], ' ', $news['poster']['link'], ' | ', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div>';

echo '
<div class="post"><hr />', $news['body'], '<br /><br /></div>
<div class="yorumbuton">
<div class="yorum ">', $news['link'], ' ',  $news['new_comment'], '</div>
</td>
</tr>
</table>
</div>
</div>';
}
}
else
{
foreach ($return as $news)
{
echo '
<div class="sp_article_content">';

if (empty($style['no_title']))
{
echo '
<div class="', in_array($style['title']['class'], array('titlebg', 'titlebg2')) ? 'title_bar' : 'cat_bar', '"', !empty($style['title']['style']) ? ' style="' . $style['title']['style'] . '"' : '', '>
<h3 class="', $style['title']['class'], '">
<span class="sp_float_left sp_article_icon">', $news['icon'], '</span><a href="', $news['href'], '" >', $news['subject'], '</a>
</h3>
</div>';
}

if (strpos($style['body']['class'], 'roundframe') !== false)
{
echo '
<span class="upperframe"><span></span></span>';
}

echo '
<div', empty($style['body']['class']) ? '' : ' class="' . $style['body']['class'] . '"', '>';

if (empty($style['no_body']))
{
echo '
<span class="topslice"><span></span></span>';
}

echo '
<div class="sp_content_padding"', !empty($style['body']['style']) ? ' style="' . $style['body']['style'] . '"' : '', '>';

if ($avatars && $news['avatar']['name'] !== null && !empty($news['avatar']['href']))
echo '
<a href="', $scripturl, '?action=profile;u=', $news['poster']['id'], '"><img src="', $news['avatar']['href'], '" alt="', $news['poster']['name'], '" width="30" class="sp_float_right" /></a>
<div class="middletext">', $news['time'], ' ', $txt['by'], ' ', $news['poster']['link'], '<br />', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div>';
else
echo '
<div class="middletext">', $news['time'], ' ', $txt['by'], ' ', $news['poster']['link'], ' | ', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div>';

echo '
<div class="post"><hr />', $news['body'], '</div>
<div class="yorumbuton">
<div class="yorum">', $news['link'], ' ',  $news['new_comment'], '</div>
</div>';

if (empty($style['no_body']))
{
echo '
<span class="botslice"><span></span></span>';
}

echo '
</div>';

if (strpos($style['body']['class'], 'roundframe') !== false)
{
echo '
<span class="lowerframe"><span></span></span>';
}

echo '
</div>';
}
}

if (!empty($per_page))
echo '
<div class="sp_page_index">', $txt['sp-articlesPages'], ': ', $page_index, '</div>';
}

I will be glad to get assisted on this. Thanks
All students forum -Global Online community for Students, Ex-Students and their friends

Offline Illori

  • Project Manager
  • SMF Master
  • *
  • Posts: 47,499
Re: Need help on Simple portal Board news code for image resizing
« Reply #1 on: April 07, 2017, 01:20:21 PM »
you would be best to post in their support topic or their support board for further assistance.

Offline drfun

  • Jr. Member
  • **
  • Posts: 185
  • Gender: Male
    • All Student Forum
Re: Need help on Simple portal Board news code for image resizing
« Reply #2 on: April 07, 2017, 11:49:32 PM »
Thanks but i have been able to fix it. everything is working well now.
All students forum -Global Online community for Students, Ex-Students and their friends