PDA

View Full Version : Show latest attachments with 'News' module



angeljs
01-12-2012, 01:02 PM
After a bit of messing around, I've managed to show the latest posts just as attachments on the CMPS front page, using the 'News' module. I'll show you how, but if anyone can come up with a better way, I'd be grateful! I'm not a programmer, so please, please back up your files before you do this!

First, edit the 'News' module. Make sure 'Enable Attachments' is set to 'Yes, First Attachment Only'. Make sure all of the other options are set to 'No', except 'Enable [ATTACH] BB Code Tags'.

I run a downloads site, and basically wanted to show just the image attachments from them, so I edited the 'adv_portal_newsbits' and changed it to this:


<vb:if condition="!$mod_options['portal_news_legacy']">

<div class="<vb:if condition="$mod_options['portal_news_legacy']">blocksubhead<vb:else />blockrow</vb:if>">
</vb:if>
<div class="blockrow">
<center><a href="{vb:raw vboptions.bburl}/{vb:link thread, {vb:raw news}}">{vb:raw news.title}</a></center>
<div<vb:if condition="$mod_options['portal_news_showrating'] AND $news['rating']"> class="vba_rating{vb:raw news.rating}"</vb:if>>
<vb:if condition="$news['subscribed'] AND $mod_options['portal_news_showsubscribed']">
<img alt="" class="inlineimg" src="{vb:stylevar imgdir_misc}/subscribed.gif" title="{vb:rawphrase you_are_subscribed_to_this_thread}" />
</vb:if>
</div>
</div>

<vb:if condition="$show['paperclip']">
<span style="float:{vb:stylevar right}">
<a href="#" onclick="vba_attach_win({vb:raw news.threadid}); return false"><img class="inlineimg" src="{vb:stylevar imgdir_misc}/paperclip.gif" border="0" title="{vb:rawphrase x_attachments, {vb:raw news.attach}}" alt="" /></a>
</span>
</vb:if>
<table width="100%">
<tr>
<td valign="top">
<vb:if condition="$news['avatarpath']">
<img align="{vb:stylevar left}" style="padding: 0 {vb:math {vb:stylevar padding}/2} {vb:math {vb:stylevar padding}/2} 0" alt="{vb:rawphrase xs_avatar, {vb:raw news.postusername}}" border="0" src="{vb:raw news.avatarpath}" />
</vb:if>

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

<vb:if condition="$show['signature']">
<div>__________________<br />{vb:raw news.signature}</div>
</vb:if>

<vb:if condition="$news['attachment']">

<fieldset>

<vb:each from="news[attachment]" value="attachment">
<vb:if condition="$attachment['hasthumb']">
<center> <a href="{vb:raw vboptions.bburl}/{vb:link thread, {vb:raw news}}"><img src="{vb:raw vboptions.bburl}/attachment.php?{vb:raw session.sessionurl}attachmentid={vb:raw attachment.attachmentid}&amp;stc=1&amp;thumb=1&amp;d={vb:raw attachment.thumbnail_dateline}" class="thumbnail" border="0" alt="Click image to view {vb:raw news.title}" width="150"></a></center>
<vb:else />
<div>
<center> <img class="inlineimg" src="{vb:stylevar imgdir_attach}/{vb:raw attachment.attachmentextension}.gif" alt="{vb:rawphrase file_type_x, {vb:raw attachment.attachmentextension}}" width="16" height="16" border="0" style="vertical-align:baseline" /> <a href="{vb:raw vboptions.bburl}/attachment.php?{vb:raw session.sessionurl}attachmentid={vb:raw attachment.attachmentid}">{vb:raw attachment.filename}</a></center>
({vb:raw attachment.filesize}, {vb:rawphrase x_views, {vb:raw attachment.counter}})

</vb:if>
</vb:each>
</fieldset>

</div>
</vb:if>
<div class="postbit vba_news">
<div class="postfoot" style="white-space: nowrap">
<div class="textcontrols floatcontainer">
<span class="postcontrols">




<vb:if condition="$mod_options['portal_news_showsendfriend']">
<span class="seperator">&nbsp;</span>
<a href="{vb:raw vboptions.bburl}/sendmessage.php?{vb:raw session.sessionurl}do=sendtofriend&amp;t={vb:raw news.threadid}" rel="nofollow" style="padding: 0"><img alt="" border="0" src="{vb:stylevar imgdir_button}/sendtofriend.gif" title="{vb:rawphrase send_to_friend}" style="position: relative" /></a>
</vb:if>

</span>
<span class="postlinking">
<vb:if condition="$mod_options['portal_news_allowreplies']">
{vb:raw news.replycount} <vb:if condition="$news['reply_noformat'] == 1">{vb:rawphrase reply}<vb:else />{vb:rawphrase replies}</vb:if>
</vb:if>
<vb:if condition="$mod_options['portal_news_showviews'] AND $mod_options['portal_news_allowreplies']"> | </vb:if>
<vb:if condition="$mod_options['portal_news_showviews']">
{vb:raw news.views} {vb:rawphrase views}
</vb:if>
</span>
</div>
</div>
</div>


Then I moved the module to the side of the page and changed the name to 'Latest Downloads' so it looks like this:

http://i605.photobucket.com/albums/tt132/angeljs/Ashampoo_Snap_20120112_16h51m43s_001_.jpg

Please note that this is just a temporary fix until someone cleverer than me comes up with a better way, and there's still that problem of guests not being able to see the attachments which I'm still waiting for someone to resolve. :(

Anyway, I hope this helps someone.