collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 384
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Welcome to SimplePortal.net! You can download SimplePortal from the Downloads Area!

Author Topic: SP articles more functions  (Read 39170 times)

0 Members and 1 Guest are viewing this topic.

Offline goten22

  • Semi Newbie
  • *
  • Posts: 20
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
SP articles more functions
« on: September 01, 2015, 02:15:50 PM »
Simpleportal has its own articles system where you can select specific topics to display on homepage. But the output is very minimalistic. I would like to see topic attachment as image or number of comments. Is this possible?

This is default output:

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: SP articles more functions
« Reply #1 on: September 01, 2015, 07:15:21 PM »
It can be adjusted to show the first attachment (if its an image) as a thumbnail aligned to the right pretty easily.

Though, what is it exactly you're looking for with the feature?

Offline goten22

  • Semi Newbie
  • *
  • Posts: 20
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #2 on: September 02, 2015, 02:06:05 AM »
How can I do this?

I'm looking for a way to display it in a bit another way not through css but by php code itself. I want to have custom php block that will display latest articles.

Offline goten22

  • Semi Newbie
  • *
  • Posts: 20
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #3 on: September 03, 2015, 04:17:24 PM »
@Sayaka, anyone, please?

Offline goten22

  • Semi Newbie
  • *
  • Posts: 20
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #4 on: September 04, 2015, 07:58:22 PM »
If I do echo $context['topic_is_article']; it shows me some random number so if I could somehow display all topics that have "['topic_is_article']!=0"?

Offline ataru

  • Jr. Member
  • **
  • Posts: 63
  • Gender: Male
    • Biancocelesti.org - Sempre Forza Lazio
  • SMF Version: 2.0.10
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #5 on: September 09, 2015, 08:55:12 AM »
I did some stuff in www.biancocelesti.org site:

the block "Notizie dal mondo Lazio" is made with a custom php block

I took an old discussion with @AngelinaBelle (http://simpleportal.net/index.php?topic=4734) and customized it adding nivo-slider jquery plugin taking 1st image in post this way:
http://simpleportal.net/index.php?topic=13798.msg68983#msg68983

here's my code:
Code: [Select]
<?php
global $smcFunc$modSettings$scripturl$user_info$txt$color_profile$smcFunc$context$settings;

$limit 15// numero totale degli articoli
$type 0// 0 = ultimi; 1 = casuale
$image 2// 0 = Nessuno; 1 = Avatar dell'utente; 2 = Categoria d'immagine
$category 0// 0 = (Tutte le Categorie)</option>; 1 = Notizie dal Campo; 2 = Notizie dalla Società; 3 = Notizie dalle Giovanili; 4 = Calciomercato; 5 = Interviste; 6 = Arbitri e moviole; 7 = Commento; 8 = Statistiche; 9 = Cronaca
$displaymessage True// False = Solo titolo; True = Titolo e testo dell'articolo
$hidebbcode False// False = Mostra; True = Nascondi
$hideauthor True// False = Mostra; True = Nascondi
$hideprnt True// False = Mostra; True = Nascondi
$shortafter 6//Mostra in maniera compatta gli articoli dopo il numero n:
$showfirstcomplete False// 
$truncate 10//
$truncatefirst 300//

$sql_qry='
SELECT
m.id_topic, m.subject, m.poster_name, m.poster_time, m.icon, c.picture, c.name, 
. (!$displaymessage '' 'm.id_msg, m.body, m.smileys_enabled, 
'
) . 'mem.id_member, mem.real_name, mem.avatar,
at.id_attach, at.attachment_type, at.filename, t.num_views
FROM {db_prefix}sp_articles AS a
INNER JOIN {db_prefix}sp_categories AS c ON (c.id_category = a.id_category)
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_message)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
LEFT JOIN {db_prefix}attachments AS at ON (at.id_member = mem.id_member)
LEFT JOIN {db_prefix}topics AS t ON (m.id_msg = t.id_first_msg)
WHERE {query_see_board}
AND a.approved = {int:approved}' 
.  
(!empty($category
'
AND a.id_category = {int:category}' 
''
) . '
ORDER BY {raw:type}
LIMIT {int:limit}'
;

$sql_params = array(
'approved' => 1,
'type' => $type 'RAND()' 'm.poster_time DESC',
'limit' => $limit
);
if (!empty($category)) $sql_params['category'] = $category;

$request $smcFunc['db_query'](''$sql_qry$sql_params);

$articles = array();
$colorids = array();
while ($row $smcFunc['db_fetch_assoc']($request))
{
if (!empty($row['ID_MEMBER']))
$colorids[$row['ID_MEMBER']] = $row['ID_MEMBER'];

if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' $modSettings['avatar_max_width_external'] . '"' '';
$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' $modSettings['avatar_max_height_external'] . '"' '';
}
else
{
$avatar_width '';
$avatar_height '';
}

censorText($row['subject']);

$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' $row['icon'] . '.gif') ? 'images_url' 'default_images_url';


$articles[] = array(
'id' => $row['id_topic'],
'name' => $row['subject'],
'icon' => '<img src="' $settings[$icon_sources[$row['icon']]] . '/post/' $row['icon'] . '.gif" align="middle" alt="' $row['icon'] . '" border="0" />',
'msg' => ( !$displaymessage NULL
array(
'id' => $row['id_msg'],
'body' => $row['body'],
'nviews' => $row['num_views'],
'smileys_enabled' => $row['smileys_enabled'
)
),
'href' => $scripturl '?topic=' $row['id_topic'] . '.0',
'link' => '<a href="' $scripturl '?topic=' $row['id_topic'] . '.0">' $row['subject'] . '</a>',
'poster' => array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl '?action=profile;u=' $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' $scripturl '?action=profile;u=' $row['id_member'] . '">' $row['real_name'] . '</a>',
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true$row['poster_time']),
'timeyear' => timeformat($row['poster_time'], '%d %b %y'),
'timeday' => timeformat($row['poster_time'], '%H:%M:%S'),
),
'image' => array(
'href' => $row['picture'],
'image' => '<img src="' $row['picture'] . '" alt="' $row['name'] . '" />',
),
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > '<img src="' . (empty($row['attachment_type']) ? $scripturl '?action=dlattach;attach=' $row['id_attach'] . ';type=avatar' $modSettings['custom_avatar_url'] . '/' $row['filename']) . '" alt="" class="avatar" border="0" />' '') : (stristr($row['avatar'], 'http://') ? '<img src="' $row['avatar'] . '" alt="" class="avatar" border="0" />' '<img src="' $modSettings['avatar_url'] . '/' htmlspecialchars($row['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > ? (empty($row['attachment_type']) ? $scripturl '?action=dlattach;attach=' $row['id_attach'] . ';type=avatar' $modSettings['custom_avatar_url'] . '/' $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' $row['avatar']),
'url' => $row['avatar'] == '' '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' $row['avatar']),
),
);

}

$smcFunc['db_free_result']($request);


$parse_tags FALSE;

$enableaeva=True;
if (array_key_exists('aeva_disable',$context))
{
$realaeva=$context['aeva_disable'];
$context['aeva_disable'] = ($enableaeva null 1);

}
elseif (array_key_exists('aeva_enable',$modSettings))
{
$realaeva=$modSettings['aeva_enable'];
$modSettings['aeva_enable'] = ($enableaeva NULL);
}

if ($displaymessage)
{

$artn=1;
foreach ($articles as $k => $article)
{
$nobbcode preg_replace('/[\ ]+/',' ',preg_replace('/<br[^>]*>/',' ',$article['msg']['body']));
$nobbcode str_replace("[img]","<",str_replace("[/img]",">",$nobbcode));
$nobbcode strip_tags(str_replace("[""<"str_replace("]"">"$nobbcode)));

$corpodellarticolo $article['msg']['body'];
$pattern "/\[img(.*?)]([^\[]+)\[\/img]/i";
preg_match_all($pattern$article['msg']['body'], $matchesPREG_SET_ORDER);
foreach ($matches as $val) {
$imgs[] = $val[2];
$corpodellarticolo str_replace($val[0],"",$corpodellarticolo);
}

$pattern "/\[url(.*?)]([^\[]+)\[\/url]/i"
preg_match_all($pattern$article['msg']['body'], $matchesPREG_SET_ORDER);
foreach ($matches as $val) {
$urls[] = $val[2];
$urlspar[] = $val[1];
$corpodellarticolo str_replace($val[0],"",$corpodellarticolo);
}
for ($spazi 0$spazi 10$spazi++) {
$corpodellarticolo str_replace("<br /><br />","<br />"$corpodellarticolo);
}
$article['msg']['body'] = $corpodellarticolo;

if ($hidebbcode && $artn $shortafter)
{
$article['msg']['body'] = $nobbcode;
}

if ($artn $shortafter)
$truncart $truncate;
else
$truncart $truncatefirst;
if (($cutoff $smcFunc['strpos']($article['msg']['body'], '')) !== false)
$putdots 
  (
   (
     $cutoff 
      ($smcFunc['strlen']($article['msg']['body']) - $smcFunc['strlen'](''
      )
    )
  ? TRUE
  : FALSE 
  );
elseif (!empty($truncart) && $smcFunc['strlen']($nobbcode) > $truncart )
{
$cutoff $truncart $smcFunc['strlen']($article['msg']['body']) - $smcFunc['strlen']($nobbcode);
$putdots TRUE;
}
else 
{
$cutoff FALSE;
$putdots FALSE;
}

if ( $cutoff !== FALSE )
{
$cut_string=substr($article['msg']['body'], 0,$cutoff);
$last_space=strrpos($cut_string," ");
$article['msg']['body']=substr($cut_string0,$last_space);
}

if ( isset($imgs) ) {
$ImgsSlide[$artn] = $imgs[0];
unset($imgs);
} else {
$ImgsSlide[$artn] = "/images/immagineNews.jpg";
}
if ( isset($urls) ) {
$UrlsSlide[$artn] = '<a href="' substr($urlspar[0], 1) . '" target="_blank">' $urls[0] . '</a>';
unset($urls);
} else {
$UrlsSlide[$artn] = "";
}
for ($spazi 0$spazi 10$spazi++) {
$article['msg']['body'] = str_replace("<br /><br />","<br />"$article['msg']['body']);
}
$article['msg']['body'] = parse_bbc($article['msg']['body'], $article['msg']['smileys_enabled'], $article['msg']['id'], $parse_tags);

if ($putdots
$article['msg']['body'] .= ' (<a href="'.$article['href'].'">...</a>)';


if ($modSettings['sp_resize_images'])
$article['msg']['body'] = preg_replace('~class="bbc_img"~i''class="bbc_img sp_article"'$article['msg']['body']);

$articles[$k]['msg']['body'] = $article['msg']['body'];
$artn++;
}

if (array_key_exists('aeva_disable',$context))
{
$context['aeva_disable'] = $realaeva;
}
elseif (array_key_exists('aeva_enable',$modSettings))
{
$modSettings['aeva_enable'] = $realaeva;
}


}

if (empty($articles))
{
echo '
'
$txt['error_sp_no_articles_found'];
return;
}
else
$articles[count($articles) - 1]['is_last']=True;

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

echo '
<table class="sp_fullwidth sp_articles">'
;
$artn=1;
foreach ($articles as $article)
{
if ($artn $shortafter)
{
echo '
<tr><td>
'
;

if (empty($image)) {}
else 
{
if (!empty($article['avatar']['href']) && $image == 1)
$img_guts $article['avatar']['href'] .  '" alt="' .  $article['poster']['name'];
elseif (!empty($article['image']['href']) && $image == 2)
$img_guts $article['image']['href'] . '" alt="' .  $article['name'];

if ( isset($img_guts) && !empty($img_guts) )
echo '<img class="sp_articles_icon" src="'$img_guts'" width="40" /></td>';
}
echo '<td>';

echo  $article['link'] ;

if ( empty($article['is_last'])) echo '
<hr />'
;
echo '</td></tr>' "\n";
}
elseif (!$showfirstcomplete)
{
if ($artn == 1)
echo'
<link rel="stylesheet" href="/jquery/nivoslider/themes/bar/bar.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/jquery/nivoslider/nivo-slider.css" type="text/css" media="screen" />
<tr><td colspan="2">
<div class="slider-wrapper theme-bar">
<div id="slider" class="nivoSlider">'
;

$htmlcaption $htmlcaption '
<div id="htmlcaption' 
$artn '" class="nivo-html-caption">
<table style="width:100%">
<tr><td style="width:70px;background-image: url(' 
$article['image']['href'] . ');background-size:64px;background-repeat:no-repeat;"></td>
<td style="color:#fff"><strong><a href="' 
$article['href'] . '" style="font-size: 200%;">' $article['name'] . '</a></strong><br />
$UrlsSlide[$artn] . '
$article['msg']['body'] . '</td></tr>
</table>
</div>'
;
echo'
<img src="' 
$ImgsSlide[$artn] , '" data-thumb="' $ImgsSlide[$artn] , '" alt="" title="#htmlcaption' $artn '" />';
if ($artn == $shortafter)
echo'
</div>' 
$htmlcaption '
</div>
<script type="text/javascript" src="/jquery/1.11.2.min.js"></script>
<script type="text/javascript" src="/jquery/nivoslider/jquery.nivo.slider.pack.js"></script>
<script type="text/javascript">
$(window).load(function() {
$("#slider").nivoSlider({
effect: "fold",                 // Specify sets like: "fold,fade,sliceDown"
//slices: 15,                     // For slice animations
//boxCols: 8,                     // For box animations
//boxRows: 4,                     // For box animations
animSpeed: 500,                 // Slide transition speed
pauseTime: 8000,                 // How long each slide will show
startSlide: 0,                     // Set starting Slide (0 index)
directionNav: true,             // Next & Prev navigation
controlNav: true,                 // 1,2,3... navigation
controlNavThumbs: false,         // Use thumbnails for Control Nav
pauseOnHover: true,             // Stop animation while hovering
manualAdvance: false,             // Force manual transitions
prevText: "Prec.",                 // Prev directionNav text
nextText: "Succ.",                 // Next directionNav text
randomStart: false//,             // Start on a random slide
//beforeChange: function(){},     // Triggers before a slide transition
//afterChange: function(){},         // Triggers after a slide transition
//slideshowEnd: function(){},     // Triggers after all slides have been shown
//lastSlide: function(){},         // Triggers when last slide is shown
//afterLoad: function(){}         // Triggers when slider has loaded
});
});
</script>
</tr></td>'
;

}
$artn++;
}
echo "</table>\n";
if ($modSettings['sp_resize_images'])
{
echo '
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var cssNode = document.createElement("link");
cssNode.type = "text/css";
cssNode.rel = "stylesheet";
cssNode.href = "'
$settings['default_theme_url'], '/css/portal_resize.css";
cssNode.media = "screen";
cssNode.title = "dynamicLoadedSheet";
document.getElementsByTagName("head")[0].appendChild(cssNode); 
// ]]></script>'
;
}
?>

« Last Edit: September 09, 2015, 09:18:37 AM by ataru »

Offline goten22

  • Semi Newbie
  • *
  • Posts: 20
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #6 on: September 09, 2015, 09:45:51 AM »
Thanks, but it doesn't work for me. I've got only two broken img tags in block. In logs I have " Undefined variable: htmlcaption". Should I modify something to make it work?

Offline ataru

  • Jr. Member
  • **
  • Posts: 63
  • Gender: Male
    • Biancocelesti.org - Sempre Forza Lazio
  • SMF Version: 2.0.10
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #7 on: September 09, 2015, 10:04:37 AM »
try saving a php file in your webspace with that code, ant then call it in a php block with

Code: [Select]
include('homepagenews.php');

for me it's working also in custom php without including it.

try adding
Code: [Select]
$htmlcaption = "";
after
Code: [Select]
$truncatefirst = 300; //
« Last Edit: September 09, 2015, 10:11:00 AM by ataru »

Offline goten22

  • Semi Newbie
  • *
  • Posts: 20
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #8 on: September 09, 2015, 04:51:30 PM »
Still doesn't work. Does it work with clean smf and SP (2.3.6) installation? Maybe I should modify some core files?

first is this code and second default block called "articles"
« Last Edit: September 11, 2015, 04:11:47 AM by goten22 »

Offline ataru

  • Jr. Member
  • **
  • Posts: 63
  • Gender: Male
    • Biancocelesti.org - Sempre Forza Lazio
  • SMF Version: 2.0.10
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #9 on: September 11, 2015, 10:35:50 AM »
Still doesn't work. Does it work with clean smf and SP (2.3.6) installation? Maybe I should modify some core files?

first is this code and second default block called "articles"


did you put nivoslider and jquery in a jquery folder on the root of your webspace?

look at that code:

Code: [Select]
<link rel="stylesheet" href="/jquery/nivoslider/themes/bar/bar.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/jquery/nivoslider/nivo-slider.css" type="text/css" media="screen" />

[...]
<script type="text/javascript" src="/jquery/1.11.2.min.js"></script>
<script type="text/javascript" src="/jquery/nivoslider/jquery.nivo.slider.pack.js"></script>

Offline goten22

  • Semi Newbie
  • *
  • Posts: 20
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #10 on: September 12, 2015, 12:56:40 AM »
I tried but still no output. Maybe if you could simplify a bit this block just to show link to the topic maybe then it will work. The number of the articles is correct but there's no link and no img.

Offline ataru

  • Jr. Member
  • **
  • Posts: 63
  • Gender: Male
    • Biancocelesti.org - Sempre Forza Lazio
  • SMF Version: 2.0.10
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #11 on: September 12, 2015, 04:05:48 AM »
What's the output html?

Offline goten22

  • Semi Newbie
  • *
  • Posts: 20
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #12 on: September 12, 2015, 08:54:41 AM »

Offline Cyberkid

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: SP articles more functions
« Reply #13 on: September 12, 2015, 07:01:03 PM »

Offline ataru

  • Jr. Member
  • **
  • Posts: 63
  • Gender: Male
    • Biancocelesti.org - Sempre Forza Lazio
  • SMF Version: 2.0.10
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #14 on: September 13, 2015, 03:42:32 AM »
Ok there is no images in articles shown, so my code tries to put /images/imagineNews.jpg as default image.

Try to put a ImagineNews.jpg file in /Images/ folder


Which version of php are you running?  Need to know why captions are not created.

Articles are empty? Try to put in articles more than 10 words
« Last Edit: September 13, 2015, 03:48:20 AM by ataru »

Offline goten22

  • Semi Newbie
  • *
  • Posts: 20
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #15 on: September 13, 2015, 04:26:11 AM »
Ok there is no images in articles shown, so my code tries to put /images/imagineNews.jpg as default image.

Try to put a ImagineNews.jpg file in /Images/ folder
...
Articles are empty? Try to put in articles more than 10 words
No changes.

Quote
Which version of php are you running?  Need to know why captions are not created.
5.3

Offline Cyberkid

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: SP articles more functions
« Reply #16 on: September 13, 2015, 08:22:21 AM »
nothing appearing here, are you sure the code is right????????

Offline ataru

  • Jr. Member
  • **
  • Posts: 63
  • Gender: Male
    • Biancocelesti.org - Sempre Forza Lazio
  • SMF Version: 2.0.10
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #17 on: September 13, 2015, 10:32:23 AM »
It's working for me. Got also Htmlcaption undefined error in log , going to fix it

Ok got why Htmlcaption is not generated

Try adding more articles or setting $shortafter lower or equal to total number of articles

I've got hundreds of articles so I never figured how to code for test forums

Other thing. My script takes images from img tags not from attachments
« Last Edit: September 13, 2015, 10:46:15 AM by ataru »

Offline goten22

  • Semi Newbie
  • *
  • Posts: 20
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #18 on: September 13, 2015, 10:51:33 AM »
Yep lowering $shortafter helps. Thank you for help.

Offline Cyberkid

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: SP articles more functions
« Reply #19 on: September 13, 2015, 02:28:55 PM »
It's working for me. Got also Htmlcaption undefined error in log , going to fix it

Ok got why Htmlcaption is not generated

Try adding more articles or setting $shortafter lower or equal to total number of articles

I've got hundreds of articles so I never figured how to code for test forums

Other thing. My script takes images from img tags not from attachments
Thanks, any way to make it both attached/image tags??? any that comes first

Offline ataru

  • Jr. Member
  • **
  • Posts: 63
  • Gender: Male
    • Biancocelesti.org - Sempre Forza Lazio
  • SMF Version: 2.0.10
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #20 on: September 13, 2015, 05:59:12 PM »
Thanks, any way to make it both attached/image tags??? any that comes first
Sure it can be done. But I don't know how to get attachments from db. I never used to check it. Sorry

Offline Cyberkid

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: SP articles more functions
« Reply #21 on: September 13, 2015, 06:07:28 PM »
 :'(

Offline goten22

  • Semi Newbie
  • *
  • Posts: 20
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #22 on: September 14, 2015, 09:06:23 AM »
An one more question. How can I display number of comments?

Offline ataru

  • Jr. Member
  • **
  • Posts: 63
  • Gender: Male
    • Biancocelesti.org - Sempre Forza Lazio
  • SMF Version: 2.0.10
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #23 on: September 14, 2015, 11:17:13 AM »
to add number of replies you have to get them in sql query adding num_replies (and eventually num_views) values from topics tab:

Code: [Select]
<?php
$sql_qry='
SELECT
m.id_topic, m.subject, m.poster_name, m.poster_time, m.icon, c.picture, c.name, 
. (!$displaymessage '' 'm.id_msg, m.body, m.smileys_enabled,
'
) . 'mem.id_member, mem.real_name, mem.avatar,
/*adding line*/
t.num_replies, t.num_views, 
/*end of added line*/
at.id_attach, at.attachment_type, at.filename, t.num_views
FROM {db_prefix}sp_articles AS a
INNER JOIN {db_prefix}sp_categories AS c ON (c.id_category = a.id_category)
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_message)
/*adding line*/
INNER JOIN {db_prefix}topics AS t ON (t.id_first_msg = a.id_message)
/*end of added line*/
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
LEFT JOIN {db_prefix}attachments AS at ON (at.id_member = mem.id_member)
LEFT JOIN {db_prefix}topics AS t ON (m.id_msg = t.id_first_msg)
WHERE {query_see_board}
AND a.approved = {int:approved}' 
.  
(!empty($category
'
AND a.id_category = {int:category}' 
''
) . '
ORDER BY {raw:type}
LIMIT {int:limit}'
;
?>


and put them into $articles array:

Code: [Select]
<?php
$articles[] = array(
'id' => $row['id_topic'],
'name' => $row['subject'],
/*adding lines*/
'replies' => $row['num_replies']
'views' => $row['num_views']
/*end of added lines*/
'icon' => '<img src="' $settings[$icon_sources[$row['icon']]] . '/post/' $row['icon'] . '.gif" align="middle" alt="' $row['icon'] . '" border="0" />',
'msg' => ( !$displaymessage NULL
array(
'id' => $row['id_msg'],
'body' => $row['body'],
'nviews' => $row['num_views'],
'smileys_enabled' => $row['smileys_enabled'
)
),
'href' => $scripturl '?topic=' $row['id_topic'] . '.0',
'link' => '<a href="' $scripturl '?topic=' $row['id_topic'] . '.0">' $row['subject'] . '</a>',
'poster' => array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl '?action=profile;u=' $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' $scripturl '?action=profile;u=' $row['id_member'] . '">' $row['real_name'] . '</a>',
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true$row['poster_time']),
'timeyear' => timeformat($row['poster_time'], '%d %b %y'),
'timeday' => timeformat($row['poster_time'], '%H:%M:%S'),
),
'image' => array(
'href' => $row['picture'],
'image' => '<img src="' $row['picture'] . '" alt="' $row['name'] . '" />',
),
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > '<img src="' . (empty($row['attachment_type']) ? $scripturl '?action=dlattach;attach=' $row['id_attach'] . ';type=avatar' $modSettings['custom_avatar_url'] . '/' $row['filename']) . '" alt="" class="avatar" border="0" />' '') : (stristr($row['avatar'], 'http://') ? '<img src="' $row['avatar'] . '" alt="" class="avatar" border="0" />' '<img src="' $modSettings['avatar_url'] . '/' htmlspecialchars($row['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > ? (empty($row['attachment_type']) ? $scripturl '?action=dlattach;attach=' $row['id_attach'] . ';type=avatar' $modSettings['custom_avatar_url'] . '/' $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' $row['avatar']),
'url' => $row['avatar'] == '' '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' $row['avatar']),
),
);
?>


and then you will find number of views and replies using variables:
Code: [Select]
$article['replies']
$article['views']

double check everything, I didn't test it, and remove '/*adding line*/' and '/*end of added line*/' from code
« Last Edit: September 14, 2015, 11:31:39 AM by ataru »

Offline ataru

  • Jr. Member
  • **
  • Posts: 63
  • Gender: Male
    • Biancocelesti.org - Sempre Forza Lazio
  • SMF Version: 2.0.10
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #24 on: September 14, 2015, 11:36:47 AM »
:'(

you should take advantage from that mod:

http://custom.simplemachines.org/mods/index.php?mod=1151

using:

Code: [Select]
, IFNULL(big.id_attach, 0) AS big_id, big.filename AS big_filename, big.width AS big_width, big.height AS big_height,
IFNULL(thn.id_attach, 0) AS thn_id, thn.filename AS thn_filename, thn.width AS thn_width, thn.height AS thn_height

Code: [Select]
LEFT JOIN {db_prefix}attachments AS big ON (big.id_msg = mf.id_msg AND big.attachment_type = 0)
LEFT JOIN {db_prefix}attachments AS thn ON (thn.id_attach = big.id_thumb)

on sql query to get images and thumbnails from database

and then cycle them to get first attachment image.

Offline Cyberkid

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: SP articles more functions
« Reply #25 on: September 14, 2015, 01:17:59 PM »
Am loving this site

Offline goten22

  • Semi Newbie
  • *
  • Posts: 20
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #26 on: September 15, 2015, 06:06:06 AM »
I've got error "Not unique table/alias: 't'"

EDIT: Got it. Sad that I still don't know much how to deal with this sql, array etc.

Code: [Select]
SELECT
m.id_topic, m.subject, m.poster_name, m.poster_time, ///add t.num_replies///, m.icon, c.picture, c.name,

Code: [Select]
$articles[] = array(
'id' => $row['id_topic'],
'name' => $row['subject'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
///add 'replies' => $row['num_replies'],////
'msg' => ( !$displaymessage ? NULL:

and then just $article['replies']
« Last Edit: September 15, 2015, 10:06:59 PM by goten22 »

Offline Cyberkid

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: SP articles more functions
« Reply #27 on: September 21, 2015, 10:12:46 AM »
:'(
you should take advantage from that mod:
http://custom.simplemachines.org/mods/index.php?mod=1151
using:
Code: [Select]
, IFNULL(big.id_attach, 0) AS big_id, big.filename AS big_filename, big.width AS big_width, big.height AS big_height,
IFNULL(thn.id_attach, 0) AS thn_id, thn.filename AS thn_filename, thn.width AS thn_width, thn.height AS thn_height
Code: [Select]
LEFT JOIN {db_prefix}attachments AS big ON (big.id_msg = mf.id_msg AND big.attachment_type = 0)
LEFT JOIN {db_prefix}attachments AS thn ON (thn.id_attach = big.id_thumb)
on sql query to get images and thumbnails from database
and then cycle them to get first attachment image.
Can this your code be done for recent post?? I mean detecting thumbnail via  [IMG] tag

Offline Cyberkid

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: SP articles more functions
« Reply #28 on: December 04, 2016, 05:48:55 PM »
Thanks, any way to make it both attached/image tags??? any that comes first
Sure it can be done. But I don't know how to get attachments from db. I never used to check it. Sorry
hi bro, i had to look for my way down here again, was still thinking if this can be done, using this mod Post and PM Inline Attachments link here http://custom.simplemachines.org/mods/index.php?mod=3770 since it uses custom bbc tags, don't know if the url of the attachment can be extracted and echo out as img tag, please help out

Offline emanuele

  • Developer
  • *
  • Posts: 293
Re: SP articles more functions
« Reply #29 on: December 05, 2016, 03:03:15 PM »
Thanks, any way to make it both attached/image tags??? any that comes first
Attachments never come "first", they are always at the end of the message.
What if there is more than one attachment? Just pick the first?
I guess you'd want the attachment only if it is an image, and the thumbnail should served (not the full size image).

Work with attachments is a bit tricky TBH, I may try to put something together, but I do not assure you anything.

Offline Cyberkid

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: SP articles more functions
« Reply #30 on: December 05, 2016, 06:10:51 PM »
Thanks, any way to make it both attached/image tags??? any that comes first
Attachments never come "first", they are always at the end of the message.
What if there is more than one attachment? Just pick the first?
I guess you'd want the attachment only if it is an image, and the thumbnail should served (not the full size image).

Work with attachments is a bit tricky TBH, I may try to put something together, but I do not assure you anything.
okay thanks bro

Offline emanuele

  • Developer
  • *
  • Posts: 293
Re: SP articles more functions
« Reply #31 on: December 08, 2016, 08:45:23 AM »
And the answers to my questions are...? ;)