将PHP论坛集成到Django网站的最佳方法? [英] Best way to integrate PHP forum into Django site?

查看:167
本文介绍了将PHP论坛集成到Django网站的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设您正在运行Django站点,并拥有一个传统的PHP论坛来支持和集成到您的站点,因为目前的Django论坛解决方案还不够成熟。



什么是最好的方法?



目前我有一个简单的视图,它呈现一个非常简单的模板,扩展了我的网站的基本模板,内容区域没有而< IFRAME> 则将论坛作为 src 。使用一个小的jQuery函数来最大限度地增加$ $ $ $ $ $ $ $ $ $ $ $ code>

但是这一切听起来很尴尬。你会怎么样?

解决方案

有几个选择。没有是理想的(但混合两个平台从来不是!)


  1. 使用iframe你建议(坏的地址在地址栏总是那个django页面,如果有人在论坛上处理一个链接,那将是PHP论坛,而不是django持有者)


  2. 使用iframe,而不是一直使用相同的 src ,解析URL并将相关位追加到iframe的src上。即如果django看到 / forum / this-url ,将src设置为 http:// forum-address / this-url 并确保所有的链接都定位到 parent 。这具有在任何时候在地址栏中显示正确链接的优点(而不是始终是/ forum /)。您需要擅自使用论坛才能正常工作。


  3. 代理内容并将其注入页面。你需要传递cookies,它可能会变得非常混乱,但是在大多数情况下,这是整合事物的好方法,因为你的链接永远是正确的。您将需要屠杀您的论坛主题,以剥离外面的所有内容,包括< body> 标签。


  4. 以与Django网站相同的方式主题您的论坛。这将提供最佳性能,但如果您在django模板中使用动态内容,则可能会遇到问题。解决这个问题的一个选择是将django模板缓存为memcache,并使用php-memcache将其拉出到您的论坛模板中。


过去我已经做了3和4。我使用了3个非常简单的表单(所以没有必要处理cookie和会话,你会)。我使用4将FluxBB论坛集成到Wordpress安装中。两个PHP都可以,但是在WordPress里面加载FluxBB 会是很麻烦的。我将动态模板事件缓存到memcache中,并将其从论坛模板中提取出来。



为此,我可能建议使用#4。这是一个痛苦的屁股必须保持两个主题,但它是迄今为止最快的解决方案。


Suppose you are running a Django site, and have a legacy PHP forum to support and integrate into your site, since current Django forum solutions are not mature enough.

What is the best way to do this?

Currently I have a simple view, which renders a very simple template which extends my site's base template, and the content area has nothing but an <IFRAME> which holds the forum as its src. A small jQuery function is used to maximize the <IFRAME>'s height (once it finishes loading) so as to contain 100% of the forum content.

But all of this sounds pretty awkward. How would you go about this?

解决方案

There are a few options. None are ideal (but mixing two platforms never is!)

  1. Use iframes as you've suggested (bad as the address in the address bar is always that of the django page and if somebody copes a link off the forum, it will be the PHP forum, not the django holder)

  2. Use iframes but instead of using the same src all the time, parse the URL and append the relative bit onto the src of the iframe. ie if django sees /forum/this-url, set the src to http://forum-address/this-url and make sure all your links target parent. This has the advantage of showing the correct link in the address bar at all times (rather than it always being /forum/). You'll need to hack your forum for this to work.

  3. Proxy the content and inject it into the page properly. You'll need to pass cookies and it might get really messy but in most terms, this is a great way to integrate things because your links will always be correct. You'll need to butcher your forum theme to strip out everything outside and including the <body> tags.

  4. Theme your forum in the same way as the Django site. This would give best performance but you might have issues if you use dynamic stuff in your django template. An option to get around this is by having the django template cache things to memcache and using php-memcache to pull them out into your forum template.

I have done both 3 and 4 in the past. I used 3 for a very simple form (so didn't have to deal with cookies and sessions as you will). I used 4 for integrating a FluxBB forum into a Wordpress install. Both PHP but it would be uber bloat to load FluxBB inside Wordpress. I cached the dynamic template things into memcache and pulled them out in the forum template.

For this, I would probably suggest going with #4. It's a pain in the arse having to maintain two themes but it's by far the fastest performing solution.

这篇关于将PHP论坛集成到Django网站的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆