开发者

Searching custom nodes' by field in Drupal?

开发者 https://www.devze.com 2022-12-29 10:11 出处:网络
Using Drupal on a project which I made custom node types in using the CCK. I want to be able to search the specific node based on a custom field the node has. So let\'s say I have this node type Artic

Using Drupal on a project which I made custom node types in using the CCK. I want to be able to search the specific node based on a custom field the node has. So let's say I have this node type Article which has a field "myfield", I want to be able to search for Articles based on the myfield field. I understand the default search module allows for searchin开发者_JAVA百科g of node types using the type:MyNodeType in the search, but I did not see any way to limit which fields are searched. Any tips? Is this something that is going to get crazy? Appreciate the help.


The default search cannot filter by specific fields.

You have a couple options.

  • Write custom code that filters again the actual fields in the database.
  • Use the Views module, which lets you filter against specific fields.
  • Install the ApacheSolr search engine, which can filter against specific fields.
    • This is a fairly complex thing to install.
    • If you're comfortable installing it, though, it's a better and more flexible search than the other two options.


Checkout the CCK Facets module. Some more details about this module (from its project page):

CCK Facets is a bundle of modules that integrate with Faceted Search to expose Content Construction Kit (CCK) fields as facets. This allows users to browse field values and to filter search results with those values.

The supported CCK field types are:

  • Text
  • Number
  • Node Reference
  • User Reference
  • Date
  • Datestamp


I use the Search API and Search API DB modules along wth Views for this.

This is a nice how to article.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号