There is a “Include full text in feeds:” option in the “RSS feeds” configuration panel but no options/method to only show excerpt instead of the “full text” or nothing for RSS feeds. This need to hack the question2answer source code. Details are in the answer.
“ RSS供稿”配置面板中有一个“在供稿中包含全文:”选项,但没有选项/方法仅显示摘录而不是“全文”,或没有供RSS供稿使用的选项/方法。 这需要破解question2answer 源代码 。 详细信息在答案中。
The changes based on Question2asnwer 1.5.4:
根据Question2asnwer 1.5.4进行的更改:
diff --git a/qa-include/qa-index.php b/qa-include/qa-index.php
index 1a5845a..f49d83c 100644
--- a/qa-include/qa-index.php
+++ b/qa-include/qa-index.php
@@ -158,7 +158,7 @@
ob_start('ob_gzhandler');
if (substr($requestlower, 0, 5)=='feed/')
- require QA_INCLUDE_DIR.'qa-feed.php';
+ require QA_INCLUDE_DIR.'qa-feed-excerpt.php';
else
require QA_INCLUDE_DIR.'qa-page.php';
}
@@ -169,4 +169,4 @@
/*
Omit PHP closing tag to help avoid accidental output
-*/
No newline at end of file
+*/
diff qa-feed.php qa-feed-excerpt.php
40a41,74
> function qa_feed_excerpt($string, $length)
> /*
> Return no more than $length characters from $string after converting it to a single line, by
> removing words from the middle (and especially towards the end)
> */
> {
> $string=strtr($string, "rnt", ' ');
>
> if (qa_strlen($string)>$length) {
> $remaining=$length-5;
>
> $words=qa_string_to_words($string, false, true);
> $countwords=count($words);
>
> $prefix='';
>
> for ($addword=0; $addword<$countwords; $addword++) {
> $word=array_shift($words);
>
> if (qa_strlen($word)>$remaining)
> break;
>
> $prefix.=$word;
>
> $remaining-=qa_strlen($word);
> }
>
> $string=$prefix.' ... ';
> }
>
> return $string;
> }
>
>
402c436,438
< $lines[]='<description>'.qa_html($htmlcontent).'</description>'; // qa_html() a second time to put HTML code inside XML wrapper
---
> $lines[]='<description>'.
> qa_html(qa_feed_excerpt($htmlcontent, 400)).
> '</description>'; // qa_html() a second time to put HTML code inside XML wrapper
432c468
< */
No newline at end of file
---
> */
The patch for question2answer 1.6.3 can be downloaded here:
可在此处下载问题2answer 1.6.3的补丁 :
0001-qa-feed-excerpt-for-question2answer.patch.
0001-qa-feed-excerpt-forquestion2answer.patch 。
Note that I copied the qa-feed.php to qa-feed-excerpt.php before this patch.
请注意,在此补丁之前,我已将qa-feed.php复制到qa-feed-excerpt.php。
翻译自: https://www.systutorials.com/question2answer-show-excerpt-in-the-rss-feed/