<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "[修正]讓主題列表時只要該主題內有一篇文章有附件便顯示附件圖示"]]></title>
		<link>https://forum.andowson.com/posts/list/7.page</link>
		<description><![CDATA[Latest messages posted in the topic "[修正]讓主題列表時只要該主題內有一篇文章有附件便顯示附件圖示"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>[修正]讓主題列表時只要該主題內有一篇文章有附件便顯示附件圖示</title>
				<description><![CDATA[ 原本JForum的設計是依某個主題最後一篇文章是否有附件來決定要不要顯示附件圖示, 但是通常容易讓網友錯過有檔案可以下載的文章,我們可以透過修改SQL語法來修正, 由於我的網站是用PostgreSQL作為後端資料庫, 故我需要修改WEB-INF/config/database/postgresql/postgresql.sql： 
<br>
[code=sql] 
<br>
TopicModel.selectAllByForumByLimit = SELECT t.*, p.user_id AS last_user_id, p.post_time, (SELECT SUM(p.attach) \ 
<br>
 FROM jforum_posts p \ 
<br>
 WHERE p.topic_id = t.topic_id \ 
<br>
 AND p.need_moderate = 0) AS attach \ 
<br>
 FROM jforum_topics t, jforum_posts p \ 
<br>
 WHERE (t.forum_id = ? OR t.topic_moved_id = ?) \ 
<br>
 AND p.post_id = t.topic_last_post_id \ 
<br>
 AND p.need_moderate = 0 \ 
<br>
 ORDER BY t.topic_type DESC, t.topic_last_post_id DESC \ 
<br>
 OFFSET ? LIMIT ? 
<br>
<br>
TopicModel.selectByUserByLimit = SELECT t.*, p.user_id AS last_user_id, p.post_time, (SELECT SUM(p.attach) \ 
<br>
 FROM jforum_posts p \ 
<br>
 WHERE p.topic_id = t.topic_id \ 
<br>
 AND p.need_moderate = 0) AS attach \ 
<br>
 FROM jforum_topics t, jforum_posts p \ 
<br>
 WHERE p.post_id = t.topic_last_post_id \ 
<br>
 AND t.user_id = ? \ 
<br>
 AND p.need_moderate = 0 \ 
<br>
 AND t.forum_id IN(:fids:) \ 
<br>
 ORDER BY t.topic_last_post_id DESC \ 
<br>
 OFFSET ? LIMIT ? 
<br>
[/code] 
<br>
登入管理介面後清除主題的Cache即可]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/165/255.page</guid>
				<link>https://forum.andowson.com/posts/preList/165/255.page</link>
				<pubDate><![CDATA[Tue, 18 Sep 2007 11:56:29]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
			<item>
				<title>回覆:[修正]讓主題列表時只要該主題內有一篇文章有附件便顯示附件圖示</title>
				<description><![CDATA[ 除了此外，要讓文章一發表時如果有附件就立即能顯示附件圖示，還要修改net.jforum.view.forum.PostAction這個類別的insertSave()和editSave()兩個methods，主要是在新增完附件後，設定Topic物件的hasAttach屬性為true。我們可透過判斷Post物件的hasAttachments()來決定剛發表或修改的文章有沒有附件，另外，為避免被最後一篇發表的文章誤導，我們還要用原本Topc已有的hasAttach()來一起判斷，只要兩個其中一個為true，即表示該主題有附件： 
<br>
insertSave(): 
<br>
[code] 
<br>
attachments.insertAttachments(p); 
<br>
t.setHasAttach(t.hasAttach() || p.hasAttachments()); 
<br>
[/code] 
<br>
editSave(): 
<br>
[code] 
<br>
attachments.insertAttachments(post); 
<br>
t.setHasAttach(t.hasAttach() || post.hasAttachments()); 
<br>
[/code] 
<br>
不過，這個方法有個bug，就是如果該主題只有一篇文章有附件，然後又把附件都刪光了，還是會顯示有附件。但是，一般來說通常發表有附件的文章後不太會去刪附件，而且重先載入JForum後也會正常顯示，所以這個應該算可以接受的bug吧！]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/165/297.page</guid>
				<link>https://forum.andowson.com/posts/preList/165/297.page</link>
				<pubDate><![CDATA[Sat, 8 Dec 2007 13:47:40]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
	</channel>
</rss>