News:

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

Main Menu

how to make ssi_boardNews shows attachment?

Started by sinbad, November 23, 2004, 11:16:01 AM

Previous topic - Next topic

evulness

hmm

other than some minor if()'s and $var name changes the only thing different really, is the query for the attachments at the end, and you removed the output method statement at the end...


these are the only real differences... beside the var name changes in the begining of the function, in with the If()'s

//my ssi doesn't have this
$message_ids = array();
//nor this, but i assume i need the above array for ID's for the following array
'attachments' => array(),


// Find their attachments.

$request = db_query("
SELECT ID_ATTACH, ID_MSG, filename, size, downloads
FROM {$db_prefix}attachments
WHERE ID_MSG IN (" . implode(', ', $message_ids) . ")", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))

{
$return[$row['ID_MSG']]['attachments'][] = array(
'name' => $row['filename'],
'downloads' => $row['downloads'],
'size' => round($row['size'] / 1024, 2) . ' ' . $txt['smf211'],
'byte_size' => $row['size'],
'href' => $scripturl . '?action=dlattach;topic=' . $return[$row['ID_MSG']]['id'] . '.0;id=' . $row['ID_ATTACH'],
'link' => '<a href="' . $scripturl . '?action=dlattach;topic=' . $return[$row['ID_MSG']]['id'] . '.0;id=' . $row['ID_ATTACH'] . '">' . $row['filename'] . '</a>'
);
}
mysql_free_result($request);
return $return;



since thats all that is different, could i just add those lines in where they need to go, and get the same result? or would i have to restructure the query to go with my $var names?

kai920

Does anyone have this working on 1.1.5?

I want to "pull the first attachment (if it exists) from the corresponding posts in ssi_boardnews"

kai920

just a small bump in case someone (who knows what to do) sees this. :)

Bancherd

Quote from: kai920 on June 11, 2008, 08:18:10 AM
Does anyone have this working on 1.1.5?

I want to "pull the first attachment (if it exists) from the corresponding posts in ssi_boardnews"

Using the code from this series of posts, I had it working on my site.  Here is the frontpage of my site: Thai Koi Keepers' Group

kai920

#24
tks Bancherd!  Did you edit SSI.php with the altered code?

kai920

I finally made some progress!  ;D I re-read, re-read, and re-read some more this entire thread and the key turned out to be unknown's post in 2004 :)

1. Had to use  $return[$row['ID_MSG']] = array(  instead of $return[] = array( ... why this is I have no idea but I'm sure some bright soul could explain.

2. How can I alter the query to display the thumbnails instead of the full image? The thumbnail would work a lot better for me as it's already re-sized by SMF and I know how big it's expected to be.

I gave it another a try and managed to spit out thumbnails as well. Just had to add ID_THUMB to the attachment query and the corresponding result to the array. I'm planning on using CSS (max-width and max-height) to slightly decrease the thumbnail size --- I like a larger tn for inside posts (the default SMF setting), but for frontpage viewing it needs to be a bit smaller.

I don't have any more questions left to contribute, for now. ;)

madman71

Would someone be kind enough to roll this into a mod?
Im sure many could use this. :D

fichtenfoo

Quote from: Reinier on February 19, 2005, 06:07:21 AM
Note that this displays only 1 attachment (which is what I want). You can easily change the code to display e.g. 3 images.

I am having trouble with displaying multiple (all) attached images using the code you created on my news page. I'm not very php proficient, just know enough to modify existing code. What should I modify based on your script to accomplish this? Thanks!!!

fichtenfoo

While I'm asking, is there a way to display the thumbnail instead of the whole attachment image?

Advertisement: