简体   繁体   English

Drupal 7:根据内容类型过滤内容

[英]Drupal 7 : Filter Content based on Content types

How do i create a dropdown box with all the content types which filter out the data on page.tpl.php. 我如何创建一个具有所有内容类型的下拉框,以过滤出page.tpl.php上的数据。 Even if I create a dropdown box myself filled with the content types , how would I able to write a functionality to filter nodes based on selected content type ? 即使我自己创建一个填充了内容类型的下拉框,我如何能够编写一种功能来根据选定的内容类型过滤节点?

  1. contextual filter 上下文过滤器
  2. When the filter value is NOT available 当过滤器值不可用时
  3. Provide default value 提供默认值
  4. PHP Code PHP代码
  5. if ($node = menu_get_object()) { return $node->type; 如果($ node = menu_get_object()){返回$ node-> type; } }

  6. apply 应用

  7. rejoice

You should check out the Views module you can use parameters passed via the url to filter data. 您应该检出Views模块,您可以使用通过url传递的参数来过滤数据。 You can generate a drop-down box using forEach in PHP using data fetched by using hooks . 您可以通过使用hooks获取的数据在PHP中使用forEach生成一个下拉框。 After that you should be able to pass the parameters to a views page and get what you are looking for. 之后,您应该能够将参数传递到视图页面,并获得所需的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM