Drupal View实现随机文章

WordPress有个插件(Random Articles WordPress Plugin)可以实现随机文章区块。Drupal好像没有随机文章(Random Articles)模块,那么Drupal怎么实现随机文章区块呢?

其实很简单,用View就可以实现随机文章。只要在Sort Criteria里面选择添加 Global: Random排序条件即可。

WordPress有个插件(Random Articles WordPress Plugin)可以实现随机文章区块。Drupal好像没有随机文章(Random Articles)模块,那么Drupal怎么实现随机文章区块呢?

其实很简单,用View就可以实现随机文章。只要在Sort Criteria里面选择添加 Global: Random排序条件即可。

下面就是随机排序设置的截图:

Drupal View实现随机文章

Drupal Ramdon Articles 设置步骤:

  1. create a new view in administer » views » add tab.
  2. give it a name. I called mine "Random".
  3. click the "Block" section heading to get its settings.
  4. enable "Provide block"
  5. choose a "View type". I went with "List View" so that I could choose which fields display in the block.
  6. type in a title. This will be the title of the block.
  7. type in a number for the amount of nodes you want to display in the block. You can use 1 (number one) if you like.
  8. click the "Fields" section heading to get its settings.
  9. add the fields you want. I chose just "Node: Title" since I wanted just links to the nodes, not the node text themselves. You should be able to choose whichever field has the quote in your CCK node.
  10. click the "Filters" section heading to get its settings.
  11. select "Node: Type" and click "Add Filter"
  12. choose the CCK node type(s) you want to appear in the block.
  13. select "Node: Published" and click "Add Filter". (I keep forgetting this one, but it’s important, since you probably don’t want to display unpublished nodes.
  14. click the "Sort criteria" section heading to get its settings.
  15. select "Random" and click "Add criteria".
  16. click "Save"
  17. click administer » blocks and enable the block you titled in step #6.

Leave a Reply

Your email address will not be published. Required fields are marked *