“链接”的最佳方式两个网页
我计划制作两个处理类似主题的网页(不同的域)。在第一页上会发布文章,我想在另一页上也显示这些文章(例如,这里仅显示最后 10 篇文章)。实现这一点的最佳方法是什么?
编辑:我使用 php/mysql
I was planing to make two web pages (different domains) which deal with similar subject. On the first page there would be published articles and I would like to show those articles on the other page also (here would be displayed for example only last 10 articles). What is the best way to realize this?
EDIT: I use php/mysql
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您应该将您的文章存储在两个页面都可用的数据库中(它们在同一个网络服务器上吗?)
然后在一个页面上您可以执行以下操作:
而在另一个页面上:
您可以从同一个网络服务器提供两个网页,即使域名不同。
You should store your articles in a database which is available from both pages (are they on the same webserver?)
Then on one page you could do this:
and on the other:
You can serve both web pages from the same webserver even if the domain names are different.
听起来您没有将两个页面“链接”在一起,而是呈现相同数据的两个不同视图 - 第一页显示完整的文章,第二页可能仅显示最后 10 篇文章的标题。
Sounds like you're not "linking" the two pages together, you're presenting two different views of the same data - the first page shows the full articles, the second page shows perhaps titles only of the last 10 articles.
如果两个站点无法访问同一数据库,则必须为第一个站点提供某种 API,以 XML、JSON 等形式导出最后 10 篇文章,并将其包含到第二个站点中。
If both sites don't have access to the same database, you have to provide some kind of API for your first site that exports the last 10 articles in XML, JSON, whatever and include this into your second site.
如果您无法在 2 个不同站点使用相同的数据库,您还可以创建最后 10 篇文章的 rss feed(或类似的),并使用它来显示其他站点上的文章!
If you don't have the possibility to use the same database from the 2 different sites, you could also create a rss feed (or similar) of the 10 last articles, and use that to display the articles on the other site!