Blog-social network based on XenForo
In this article I will try to briefly talk about the construction of the analog of Livestreet on the basis of XenForo. The whole blogging social network is a plugin for XenForo called Social. architecture Overview engine and the basics of playepisode are FractalizeR.
After analyzing the architecture of XenForo, we realized that fundamental differences forum from the blogs not so much. Indeed, the first message of the topic easily turns into the article, and the rest of the posts — in the comments. Certain sections of the forum can be turned into blogs.
The main advantages of this solution.
the
Of course, this approach has its drawbacks.
the
In General, the idea that any discussion is the theme, seemed very logical. The division of topics and articles in the end was not so difficult. Now about the highlights of the technical implementation of the plugin.
Make the setting
Extensible classes
Now anywhere in the script we know that are inside of the blog.
Extensible class
As parameters of the pattern transferred to the first post and renderanno tree reviews. It remains only to insert this tree to the end of the first post using the template hook called
It turns out that themes can be used as a universal way of comments any content. We show this by the example of photo albums. Out of the box you can upload photos as attachments to messages, and browse with the built-in lightbox.
Again, we will create a configuration
All albums of one user now can fit in one tree subject to the following:
the
Then you can act similar blogs: do write to the registry, expanding the view and change the template. The technical details go, it makes no sense.
Newsline has its own controller, view and template. Every news is a processed first message in a topic. The process is automatic pruning, and to limit the number of embedded images and videos. The news appears on the home if the first message of the topic collects more than a specified number of likes. Through this approach, the news can be an article, a photo album, a survey or simple discussion.
XenForo seemed to us one of the most thoughtful and technological scripts, not only among forum engines, but also among CMS. Now I am convinced that on the basis of XenForo can be done as a major portal and social network.
The project is developing. The bulk of the blogs are ready. Plans photo albums, CMS, online shop, wiki, poster. If anyone is interested to participate — write. If you are interested to see demo, I will add a link.
Article based on information from habrahabr.ru
After analyzing the architecture of XenForo, we realized that fundamental differences forum from the blogs not so much. Indeed, the first message of the topic easily turns into the article, and the rest of the posts — in the comments. Certain sections of the forum can be turned into blogs.
The main advantages of this solution.
the
-
the
- Built-in forum. the
- system Ready BBCodes and processing messages. the
- of Turning articles into topics and themes in the articles by transferring to the desired section. the
- the plugin Code is very compact.
Of course, this approach has its drawbacks.
the
-
the
- For proper separation of functionality had to learn the engine inside and out. the
- Less freedom of action, as the articles expand the topic.
In General, the idea that any discussion is the theme, seemed very logical. The division of topics and articles in the end was not so difficult. Now about the highlights of the technical implementation of the plugin.
Blogs
Make the setting
socialBlogRoot
that defines the parent node for all blogs. Ie all the child forums of the node socialBlogRoot
needs to turn into blogs, and topics of these forums — to articles. Add the parent_post_id
to table xf_post
for the tree comment.Controller
Extensible classes
XenForo_ControllerPublic_Thread
and XenForo_ControllerPublic_Forum
. If the current forum is a child of the socialBlogRoot
, make the entry in the registry:XenForo_Application::set('blogView', 1);
Now anywhere in the script we know that are inside of the blog.
Views
Extensible class
XenForo_ViewPublic_Thread_View
:
class Social_ViewPublic_Thread_View extends XFCP_Social_ViewPublic_Thread_View
{
public function renderHtml()
{
parent::renderHtml();
// If the theme is article, do tree comments
if (XenForo_Application::isRegistered('blogView'))
{
$firstPostId = $this->_params['firstPost']['post_id'];
$this->_params['firstPost'] = $this->_params['posts'][$firstPostId];
// Reserve all the posts except the first
unset($this->_params['posts'][$firstPostId]);
// Build tree reviews
$commentTree = Social_ViewPublic_Helper_Comment::buildCommentTree($this->_params['posts']);
$this->_params['commentsTemplate'] = Social_ViewPublic_Helper_Comment::createCommentsTemplateObject($this, $commentTree);
// In the template is served the first post and renderanno tree of commentaries
$this->_params['posts'] = array($this->_params['firstPost']['post_id'] => $this->_params['firstPost']);
}
}
}
Template
As parameters of the pattern transferred to the first post and renderanno tree reviews. It remains only to insert this tree to the end of the first post using the template hook called
ad_message_below
in sablone message
.Module reviews based on themes
It turns out that themes can be used as a universal way of comments any content. We show this by the example of photo albums. Out of the box you can upload photos as attachments to messages, and browse with the built-in lightbox.
Again, we will create a configuration
socialAlbumRoot
for the root of all the albums. For blogs we made the tree comments. Now message can apply not only to another message, but also to the attachment. To do this, instead of adding one field parent_post_id
to table xf_post
add the two fields target_id
and target_type
. The latter indicates the content type of the message (post or attachment).All albums of one user now can fit in one tree subject to the following:
the
-
the
- Album (post: target_id=0, target_type=post, post_id=200 )
the-
the
- Photo (attachment: target_id=200, target_type=post, attachment_id = 1000)
the-
the
- Comment (post: target_id=1000, target_type=attachment, post_id=201 ) the
- Comment (post: target_id=1000, target_type=attachment, post_id=202 )
the - Photo (attachment: target_id=200, target_type=post, attachment_id = 1001)
the-
the
- Comment (post: target_id=1001, target_type=attachment, post_id=204 ) the
- Comment (post: target_id=1001, target_type=attachment, post_id=205 ) the
- Comment (post: target_id=1001, target_type=attachment, post_id=206 )
the - Photo (attachment: target_id=200, target_type=post, attachment_id = 1000)
- Album (post: target_id=0, target_type=post, post_id=201 )
the-
the
- Photo (attachment: target_id=201, target_type=post, attachment_id = 1002)
the-
the
- Comment (post: target_id=1002, target_type=attachment, post_id=207 ) the
- Comment (post: target_id=1002, target_type=attachment, post_id=208 ) the
- Comment (post: target_id=1002, target_type=attachment, post_id=209 )
the - Photo (attachment: target_id=201, target_type=post, attachment_id = 1003)
the-
the
- Comment (post: target_id=1003, target_type=attachment, post_id=210 ) the
- Comment (post: target_id=1003, target_type=attachment, post_id=211 ) the
- Comment (post: target_id=1003, target_type=attachment, post_id=212 )
- Photo (attachment: target_id=201, target_type=post, attachment_id = 1002)
Then you can act similar blogs: do write to the registry, expanding the view and change the template. The technical details go, it makes no sense.
news (main)
Newsline has its own controller, view and template. Every news is a processed first message in a topic. The process is automatic pruning, and to limit the number of embedded images and videos. The news appears on the home if the first message of the topic collects more than a specified number of likes. Through this approach, the news can be an article, a photo album, a survey or simple discussion.
Opinion
XenForo seemed to us one of the most thoughtful and technological scripts, not only among forum engines, but also among CMS. Now I am convinced that on the basis of XenForo can be done as a major portal and social network.
The project is developing. The bulk of the blogs are ready. Plans photo albums, CMS, online shop, wiki, poster. If anyone is interested to participate — write. If you are interested to see demo, I will add a link.
Комментарии
Отправить комментарий