[Tutorial] Modding the Resource Manager to an Article Manager

Обещать не буду, очень мало времени свободного.
У самого стоит задача по размещению статей с выводом их на главную страницу.
На сколько для этой задачи подойдет Resources, сказать не могу. Может, и какое лучшее решение найдется.
Но, по мере сил, вклад в общее дело делать буду.
 
  • Мне нравится
Реакции: Hope
previewam.png

Please note that this guide is no replacement for a proper add-on and should only be used if you know what you're doing. This is based on the Resource Manager 1.0.0 and XenForo 1.1.X. It will not be updated to future versions

The Resource Manager aims to provide you with all sorts of resources, including news/articles. If you are sure you only want to use the RM for articles, you can mod the resource manager to an article manager. You have to strip out unneeded features and customize certain things to emulate an article manager. This is a step-by-step guide that helps you to accomplish this. This guide will not change any admin templates. Template changes are made with TMS only, so obviously you have to install that as well. Please note that you can't install more than one copy of the resource manager, so you will be able to use it as an article manager only. Oh and did I mention that upgrading to a newer version of the Resource Manager will be a pain? You have been warned.

1. Renaming the resources route

Obviously you want to rename the resource route to a phrase better fitting for articles. Download Jake's Route Changer and change the resources route to articles.

2. Stripping out resource tabs from resource index and category pages

There is no point to have those resource tabs with an article manager. Hiding them with CSS is bad, so you have to get rid of them from the html via a TMS template edit.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit is resource_index. Call the modification strip_tabs_from_index. Under the description field type "Strips out resource tabs from index". Use the Preg Replace method and copy&paste the following in the Search field:
Код:
#(<div class="resourceHeaders">.*?</div>)#s


Leave the Replace field blank and save.

We need to repeat the process for the category page as the edit above only strips the tabs out of the resource manager index page.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit now is resource_category. Call the modification strip_tabs_from_category_pages. Under the description field type "Strips out resource tabs from category pages". Use the Preg Replace method and copy&paste the following in the Search field:
Код:
#(<div class="resourceHeaders">.*?</div>)#s


Leave the Replace field blank and save.

3. Stripping out sidebar blocks

We are going to strip out the sidebar blocks Top Resources and Most Active Authors. Top Resources are not needed because we are going to disable resource rating later in this guide. If only your staff can write articles, the Most Active Authors blocks isn't needed.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit again is resource_index. Call the modification strip_top_resources_block_from_index. Under the description field type "Strips out top resources block from index". Use the Preg Replace method and copy&paste the following in the Search field:
Код:
#(<xen:if is="{\$topResources}">.*?</xen:if>)#s


Leave the Replace field blank and save.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit again is resource_index. Call the modification strip_most_active_authors_block_from_index. Under the description field type "Strips out most active authors block from index". Use the Preg Replacemethod and copy&paste the following in the Search field:
Код:
#(<xen:if is="{\$activeAuthors}">.*?</xen:if>)#s


Leave the Replace field blank and save.

The Top Resources and Most Active Authors blocks are now gone from the resource manager index page. At this point, the Most Active Authors block is also gone from category pages because its template is fetched from the index page. And since we have deleted it, there is no Most Active Authors block anymore on category pages. Next is to remove the Top Resources block from category pages.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit again is resource_category. Call the modification strip_top_resources_block_from_category_pages. Under the description field type "Strips out top resources block from category pages". Use the Preg Replace method and copy&paste the following in the Search field:
Код:
#(<xen:if is="{\$topResources}">.*?</xen:if>)#s



Leave the Replace field blank and save.

4. Trimming the navigation

Because we have removed the Most Active Authors block, we need to remove the link to the most active authors page from the navigation as well.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit is resources_tab_links. Call the modification strip_most_active_authors_link_from_navigation. Under the description field type "Strips out most active authors link from the navigation". This time use the String Replace method and copy&paste the following in the Search field:
Код:
<li><a href="{xen:link resources/authors}">{xen:phrase most_active_authors}</a></li>


Leave the Replace field blank and save.

Please note that users can still access the most active authors page if they know the link (it isn't hard to figure it out). Stopping access to this page is out of the scope of this guide.

5. Changing the alignment of the reource list sidebar to right

With an article system, the most important content should be on the left side (because we read from left to right). The category box is less important than the articles, so it should be placed right from the article list. We can accomplish this with CSS. Please understand that we won't put our CSS in the EXTRA.css template to retain the "click-and-enable click-and-disable" feel of TMS.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit is resource_list.css. Call the modification align_resource_list_sidebar_right. Under the description field type "Aligns the resource list sidebar to the right side". Use the String Replace method and copy&paste the following in the Search field:
Код:
.resourceCategoryTooltip
{


Now copy&paste the following in the Replace field:
Код:
.resourceListSidebar
{
float: right !important;
}

.resourceListMain
{
margin-left: 0px !important;
margin-right: 230px !important;
}
.resourceCategoryTooltip
{


Now save.

6. Stripping out resource stats from resource list

You don't need to update articles the way resources here at xenforo are updated, because articles don't have versions. You also don't need reviews for articles because the Like system is good enough and you want to separate content from gigs. So we are going to remove them. Make sure you disable reviews via user group permissions.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit is resource_list_item. Call the modification strip_stats_from_resource_list. Under the description field type "Strips stats from resource lists". Use the Preg Replace method and copy&paste the following in the Search field:
Код:
#(<div class="listBlock resourceStats">.*?</div>.*?</div>.*?</div>)#s


Leave the Replace field blank and save.

7. Increasing font-size of titles and making an SEO adjustment

The font-size of the resource titles is 11pt. This is just too low for article titles. So we need to increase it. Also the resource titles are in h3 tags. For better SEO we are going to change them to h2 tags.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit is resource_list.css. Call the modification increase_font_size_of_titles. Under the description field type "Increases the font-size of titles in resource list". Use the String Replace method and copy&paste the following in the Search field (paste it exactly like you see it. Don't miss any indentations or the modification will not apply):
Код:
.resourceListItem .main .title
{


Now copy&paste the following in the Replace field:
Код:
 .resourceListItem .main .title
{
font-size: 14pt !important;
font-weight: normal !important;
}

.resourceListItem .main .title
{


Now save. It's turn to change the h3 tags.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit is resource_list_item. Call the modification change_h3_to_h2. Under the description field type "Changes h3 tags with h2 tags for better SEO". Use the Preg Replace method and copy&paste the following in the Search field:
Код:
#(<h3 class="title">.*?</h3>)#s


Now copy&paste the following in the Replace field:
Код:
<h2 class="title">
<xen:if is="{$resource.canInlineMod} AND !{$hideInlineMod} AND !{$showCheckbox}"><input type="checkbox" name="resources[]" value="{$resource.resource_id}" class="InlineModCheck" id="inlineModCheck-resource-{$resource.resource_id}" data-target="#resource-{$resource.resource_id}" title="{xen:phrase select_resource}: '{$resource.title}'" /></xen:if>
<xen:if is="{$showCheckbox}"><input type="checkbox" name="resource_ids[]" value="{$resource.resource_id}" /> </xen:if><a
href="{xen:link resources, $resource}">{$resource.title}</a>
<xen:if is="!{$resource.isFilelessNoExternal}"><span class="version">{$resource.version_string}</span></xen:if>
</h2>


Now save.

8. Stripping out avatars from resource lists (optional)

This step is optional. If you don't want to remove avatars you can skip this step.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit is resource_list_item. Call the modification strip_avatars_from_resource_lists. Under the description field type "Strips out avatars from resource lists". Use the Preg Replace method and copy&paste the following in the Search field:
Код:
#(<div class="listBlock resourceIcon">.*?</div>.*?</div>)#s


Leave the Replace field blank and save.

We are now going to modify the look of the actual articles.

9. Stripping out resource tabs from article pages

You don't need the overview and the discussion tab because there already is a button which leads to the discussion and you don't need the reviews tab because you don't want article reviews. You also don't need the updates tab because your articles don't have versions.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit is resource_view_tabs. Call the modification strip_tabs_from_article_pages. Under the description field type "Strips out tabs from article pages". Use the Preg Replace method and copy&paste the following in the Search field:
Код:
#(<ul class="tabs resourceTabs">.*?</ul>)#s


Leave the Replace field blank and save.

10. Stripping out resource update button

Because we won't update articles the way we update addons, the resource update button is unneeded. We could remove the button with usergroup permissions, but this would make articles not editable at all, so we must use a template edit. This will also remove the link in the sidebar.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit is resource_view. Call the modification strip_post_update_button. Under the description field type "Strips resource update button from article pages". Use the Preg Replace method and copy&paste the following in the Search field:
Код:
#(<xen:if is="{\$resource.canAddVersion}">.*?</xen:if>)#s


Leave the Replace field blank and save.

11. Format article view header

We are going to remove the avatar from the titles, because we will place it elsewhere later. Also we will separate title from content with a border.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit is resource_view_header. Call the modification remove_avatar_from_title. Under the description field type "Removes the avatar from the title". Use the Preg Replace method and copy&paste the following in the Search field:
Код:
#(<xen:hook name="resource_view_header_info">.*?</a>)#s


Now copy&paste the following in the Replace field:
Код:
<xen:hook name="resource_view_header_info">


Save.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit is resource_view_header.css. Call the modification border_between_title_and_content. Under the description field type "Adds a border between article titles and content". Use the String Replace method and copy&paste the following in the Search field:
Код:
.resourceInfo
{


Now copy&paste the following in the Replace field:
Код:
.resourceInfo
{
border-bottom: 1px solid @primaryLighter;
padding-bottom: 10px;


Save.

12. Adding post date and author below the content

To retain consistency with the xenforo postbit, we are going to move post date and author below content in the private controls.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit is resource_update. Call the modification author_timestamp_below_content. Under the description field type "Adds article post date and author below content". Use the String Replace method and copy&paste the following in the Search field:
Код:
<span class="privateControls">


Now copy&paste the following in the Replace field:
Код:
<span class="privateControls">
<span class="muted item">{xen:phrase posted_by}
<a href="{xen:link resources/authors, $resource}">{$resource.username}</a>,
<xen:datetime time="$resource.resource_date" />
</span>


Save.

13. Customizing sidebar and clean-up

Here we are going to remove the ratings and last update field from the informations block and add the authors avatar.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit is resource_view. Call the modification strip_last_update_field. Under the description field type "Strips out the last update field from the informations block of the sidebar". Use the Preg Replace method and copy&paste the following in the Search field:
Код:
#(<dl class="lastUpdate">.*?</dl>)#s


Leave the Replace field blank and save.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit is resource_view. Call the modification strip_review_field. Under the description field type "Strips out the review field from the informations block of the sidebar". Use the Preg Replace method and copy&paste the following in the Search field:
Код:
#(<xen:include template="rating">.*?</xen:include>)#s


Leave the Replace field blank and save.

- Go to Appearance → Template Modifications and create a new template modification.
- The template we have to edit is resource_view. Call the modification author_details. Under the description field type "Adds author details in the informations block of the sidebar". Use the String Replace method and copy&paste the following in the Search field:
Код:
<dl class="author">


Now copy&paste the following in the Replace field:
Код:
<xen:avatar user="$resource" size="s" img="true" />
<dl class="author">


Save.

14. Renaming phrases

Finally we have to rename phrases because we have articles, not resources. I beg forgiveness if I have missed some phrases. We don't need to rename all phrases though.

resources
selected_resources
add_resource
first_release
discuss_this_resource
resource_tools
edit_resource
delete_resource
delete_resources
inline_moderation_delete_resources
undelete_resource
undelete_resources
you_sure_want_delete_resource
unapprove_resource
unapprove_resources
reassign_resource
reassign_resources
reassign_resource_thread
inline_moderation_reassign_resources
you_may_only_reassign_resource_to_user_with_permission_to_view
you_sure_you_want_to_reassign_x_resources
more_resources_from_x
provide_very_brief_one_line_description_of_your_resource
provide_n_depth_description_resource
watched_resources
your_resources
search_resources
search_resources_only
x_liked_your_resource_y
select_category_that_best_describes_your_resource
name_by_which_resource_known_and_version
you_not_currently_watching_any_resources
requested_user_has_no_resources

Enjoy and again only do this if you definitely will use the RM for articles only and know what you are doing.
 
Кому-то удалось воплотить это дело?
У меня встала задача разместить множество статей на сайте. Будет что-то на подобии википедии...
И вот ищу мод с нужным мне функционалом. Пробовал ArticleManager 2.0.8 но там основной функционал не работает. Теперь вот подумываю приспособить под это дело ResourceManager. В нем, на вскику если посмотреть, кажется что всего то и нужно - переименовать некоторые пункты из "Ресурсы" в "Статьи"...
 
Есть же модули переделки, зачем велосипед городить?
прошу прощения, вы имеете в виду, например, RM: Article Translation (This is a high quality translation that turns the Resource Manager into an Article Manager.) ?
 
Современный облачный хостинг провайдер | Aéza
Назад
Сверху Снизу