国外设计欣赏网站 - DOOOOR.com

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,微信登陆

搜索

[Drupal模块] Drupal模块介绍7.X,6.X: Similar By Terms根据Tag列出相关文章列表

[复制链接]
发表于 2-16-2012 23:22 | 显示全部楼层 |阅读模式

在做网站的时候,在单个node 想加上有关文章,使用到这个模块:Similar By Terms http://drupal.org/project/similarterms 。可以列出相似的文章列表。

# a+ [8 {+ \- O0 l2 M8 w

 

) ?$ B8 V5 }6 V& b5 F

用起来还不错,安装然后设置,可以在区域里面添加具体的区块。我就放在内容页面下面。不过好像每次相关文章都是一样的。

, R6 } ^% Q$ [: C# B; a: }+ X

 

2 o9 P" ^& _, t1 q6 h

最后找了半天,修改了Similar By Terms 模块里面的similarterms.module 文件 把排序改为随机 $sql .= ‘ORDER BY rand() DESC, ‘ 测试还可以。

. `/ c' }" o$ u- T3 I

 

$ L! g* ~, {/ {' J9 X" L% M

但是觉得摘要长了,也不知道在什么地方改,最后看到similarterms.tpl.php,这是这个模块的模板文件,唉,现在还不会用Drupal的APi,用PHP 函数strip_tags(substr($node->teaser,0,400)) 去掉多余的HTML 摘要也变为自己想要的长度了。

, M- B: X4 I2 k( e- k3 i


 

6 J/ j) E& ?3 P) b; t

 

" o3 U2 [7 s) m( |

-----------------------------------------------------------------------------------------------------------------------------------------

- W; Q* S" ?& [) N& R

 

" [3 |, ?3 C4 w$ l( d O# h

 

# R- b+ `0 p! z+ F% h

3 e1 s% {% [% c$ P

: P7 h/ h: I, ]& p1 {9 s

Similar By Terms0 Q/ B" h% `7 P8 a. ]. Z9 T
# J3 z# u1 f* V* v6 z1 s
- q% V* Q: c# e) y
) t! T. [8 U+ W/ ~( B1 d' G9 t
" m5 O6 N! h' R- f, w, N1 H" w
( a( C; n( c3 q, x7 @
- `' ]6 c" Z3 [) S, U6 C1 ~
% J/ g- u: D" c

 

# w5 I2 b7 t! t$ Y' Y; B; y

 

0 j) v& y- `2 H m& |8 \ Q

This Drupal module attempts to provide context for content items by displaying a block with links to other similar content. Similarity is based on the taxonomy terms assigned to content. Blocks are available based on similarity within each of the defined vocabularies for a site as well as a block for similarity within all vocabularies.

; n" O8 I; `5 w) `- e

What does this really mean? How should you use this module?

; ^1 w5 i$ ?3 F1 s& c+ s

1) Create a freetagging vocabulary called "Tags" assigned to the content types on which you'd like to display the "Similar" block.
2) Enable the block called "Similar entries from the Tags vocabulary".
3) Add keyword tags to the content.

8 }5 [& d/ @! K1 t' l- G4 ^

Done!

8 y. E6 [! ^/ u

Now when you go to the page for a tagged content item, a block will show up displaying other content in descending order of common tags (terms).

7 g/ k) }( \/ n6 h4 n+ {

You may be interested in comparison shopping: Comparison of Similar / Relevant by term block modules..

; F% V) |3 w' P% [

Similar By Terms 2

/ G5 U0 m/ t3 x4 @- M

Similar By Terms 2 is a complete rewrite of Similar By Terms as a Views plug-in. It offers much more flexibility than the original version. The module provides a default view which exposes a block which should function exactly the same as Similar By Terms 1. However, Views can be customized or cloned to add different fields, filters, output formats, or any of the good stuff we've come to expect from Views.

, f1 l5 z/ [' `1 g

Find complete documentation for Similar By Terms 2 in the README file or visit the GitHub repository to read it online.

8 p9 g" w5 @1 @3 M

Before upgrading from Similar By Terms 1 (SBT1) to Similar By Terms 2 (SBT2) please read the upgrade instructions. Since the versions are so different, you will need to enable and configure the SBT2 blocks manually after upgrading. If you are familiar with Views, this is a very easy process.

l8 D3 F. T" K/ \7 u, ?

Similar By Terms Drupal 7.x-1.x

0 W) h% v% L/ i8 N: R

7.x-1.x is based on Similar By Terms 6.x-1.x branch and not the 2.x branch so no views support. Sorry I started the 7.x branch before Jeff started working on the 2.x branch. 7.x-2.x will be views based and based on Similar By Terms 2.

; i; k9 P$ O1 M4 G+ v3 \

Beta 1 is released this is the 1st version that I have trusted on my production sites. It still needs some testing but I haven't had any issues running it on my production sites.

- `# y5 m6 E5 m9 B" C

Issues

5 |8 O/ n( E8 U M6 b# N

As with all contributed modules, when considering submitting an issue:

/ O4 {% L0 L; C- X y: P
    , L6 w+ p h/ I, M" \
  1. Clear the Similar by Terms Cache.
  2. 4 i- z" I. d, c) O, Y: A, E+ H
  3. Read the documentation (two or three times is better).
  4. ( W+ s$ I: T, E: c9 i( `/ Y
  5. Review the existing issues list. (Don't forget to select "<all>" for the "Status" field.)
  6. $ `: {: C, D# G) G
  7. Gather all the appropriate information. This may include (but is not limited to):
  8. 3 I2 H" m' ?% q0 a
      * F* }7 ]6 U# x6 }$ F( c; o2 p
    • Drupal version.
    • 5 t! H( l/ L+ @2 L! @. O6 r: }
    • Browser type and version.
    • + ~& ?7 S" L& v% K0 j' m4 ^, W/ Z: R
    • Database type and version.
    • 0 r. u7 R6 m! _/ X
    • Error messages, if any.
    • X6 O2 A" o- p7 U, D0 ?
    • Module settings.
    3 J$ ]% p- J, `6 y) _
  9. Submit the issue. If other modules are involved, you may need to submit the issue to those modules as well.
; W+ v% d, M0 u) ?3 v

PHP 4 and MySql 4

8 V+ J' p+ t$ y. Z

Due to end-of-life on PHP4 and MySql4, we no longer actively support either of those products. If a problem arises, we will make an effort to work around it, but will not make a guarantee. Drupal 7 will require PHP 5.2.5 or higher and MySql 5 (or Postgres 8); if your host is not at these levels yet, please encourage them to get there ASAP.

% A1 G( @5 W# T% T5 j/ b

The module was originally created by Jeff Robbins and sponsored by Lullabot.

4 D& m2 H$ G V; [" V

4 T* \0 P* H1 F3 |! n: p* |+ G$ u- i

Downloads

/ v- u& \ M9 l8 O% V+ _

 

$ ~! M/ N1 G7 t! u; k' m" X

 

|2011-2026-版权声明|平台(网站)公约|DOOOOR 设计网 ( 吉ICP备2022003869号 )

GMT+8, 2-19-2025 13:40 , Processed in 0.385352 second(s), 54 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表