如何为论坛编写线程?
首先,我不是在寻找实际的代码;我什至不需要代码。
我只想了解我需要使用哪些工具以及我想要做的事情背后的逻辑,因为目前我不知道如何完成这项任务。
我正在尝试创建一个类似 stackoverflow 的论坛(不完全是论坛,但类似)。我感到困惑的部分是,当用户单击“提问”在论坛上创建新线程时,输入标题和问题本身并单击“提交线程”后,该线程如何放置在新容器中的主页?
我是否必须使用 html 创建一个容器并将其保存在数据库中,当用户单击“提交”时,该容器将回显到主页上?老实说,我不知道它会如何运作。请提前提供帮助并致谢。
PS我不是一个经验丰富的程序员,我有接近中级的经验,但我需要清晰的解释。
First off, i'm not looking for actual code; i don't even want code.
I just want to understand what tools i need to use and the logic behind what i'm trying to do because, at the moment i have no idea how to go about this task.
I'm trying to create a forum(not exactly a forum but similar) like stackoverflow. The part i'm confused about is, when a user clicks on "Ask Question" to create a new thread on the forum, after typing in the title and the question itself and clicking "submit thread", how does that thread get placed on the homepage in a new container?
Would i have to create a container using html and save it inside a database somehow and when the user clicks submit, that container would be echoed on to the homepage? I honestly have no idea how it would work. Please help and thanks in advance.
P.S I'm not a highly experienced programmer, i have close to intermediate experience but i need clear explanations.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一英里高的视野可能正是您目前所需要的。
您的数据库中有一个线程表,它有许多相关的信息。帖子标题、帖子所有者、发布时间、类别、标签、实际内容、更新时间
您的主页将对数据库运行查询,并查找按发布时间和更新时间排序的问题。
这将为您提供最近线程的列表,无论是新的还是最近回复的。
但是,如果您不确定其编码,并且目前无法考虑数据库组件,那么最好考虑使用现成的论坛、.Net Nuke、PHP Nuke、simple Machines论坛和许多其他内容都可以自由定制。
您甚至可以使用 Stack Overflow API 创建您自己的问答板!
以下是 Stack API 其他用法的网址:https://stackapps.com/
A mile high view is probably what you need at the moment.
You'd have in your database a table for threads, it would have a number of relevant pieces of information. Post title, Post owner, Time posted, Category, Tags, Actual content, time updated
Your homepage would run a query against the database and find questions ordering by Time Posted and time updated.
This would give you a list of recent threads, either new or recently replied to.
However, if you're not sure about the coding of this, and can't consider the database components at present, then it might be better to consider getting an off-the-shelf forum, .Net Nuke, PHP Nuke, simple Machines forum and many others are out there and freely customizable.
You can even use the Stack Overflow API to create your own Q&A board!
Here's a url for other usages of the Stack API: https://stackapps.com/
单击“提交线程”将在数据库中创建一个线程对象。然后,您可以使用该对象在主页上创建它的小视图,并在其自己的页面上创建它的完整视图。
基本上,主页后面的代码会向数据库询问按创建日期降序排列的 Thread 对象列表,并限制一定数量的对象,并用每条记录的数据填充模板。
Clicking "submit thread" would create a Thread object in your database. You could then use this object to create a small a view of it on your homepage, and a full view of it on its own page.
Basically, the code behind the homepage would ask the db for a list of Thread object ordered by descending creation date, and limited to a certain amount of object, and fill a template with the data for each record.
只需使用谷歌查找一些论坛教程/示例,如果您在检查这些教程/示例后仍然有疑问,您可以回到这里并提出更具体的问题。
此外,编程上下文中的线程与论坛线程完全不同,仅供参考。
Just use google to find some forum tutorials/examples, if you still have questions after examining those you can come back here and ask more specific questions.
Also, threads in a programming context are completely different from a forum thread, just fyi.