使用Drupal 6,使用暴露过滤器的视图2,我正在尝试确定将选择列表转换为链接列表的最佳方法,每个链接都包含匹配节点的计数。例如,而不是我默认获得的,作为选择列表:
<select name="state" class="form-select" id="edit-state" >
<option value="All" selected="selected"><Any></option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
...
</select>
我想得到像
这样的东西<p>Restrict results by state:<br />
<a href="...">Alabama (15)</a><br />
<a href="...">Alaska (7)</a><br />
...
</p>
每个链接在括号中显示计数并向下钻取,就像选择第一个代码块中的一个选项一样。
你能提供一些关于如何解决这个问题的指示吗?感谢。
答案 0 :(得分:2)
您可能需要查看Better Exposed Filters模块以查看视图。 7.x版本具有此功能,并且还有6.x版本的补丁,可在以下位置找到:
答案 1 :(得分:1)
Solr很光滑,但也查看了Views中的摘要选项。您可以在Views附带的“存档列表”视图的参数部分中看到此示例。
drupal.org上还有一些其他方面的浏览模块,但我没有任何个人经验。
答案 2 :(得分:0)
你所追求的不是意见的意图。它可能会这样做,但实施起来会很慢而且很难。
相反,你应该看看Acquia为Apache Solr制作的模块。它确实面向搜索,这是你真正想要做的。如果你的情况足够简单,你可能不需要那么花哨的东西。但是你做的只是时间问题。性能将成为一个大问题,因为您需要按状态执行查询才能获得计数。
答案 3 :(得分:0)
检查此问题http://drupal.org/node/891974。 代码是针对每页的帖子数量,但也可以轻松地对其他过滤器进行。
答案 4 :(得分:0)
import java.awt.GridLayout;
import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TicTacToe {
private JFrame frame;
private JPanel contentPane;
private JButton row1col1, row1col2, row1col3, row2col1, row2col2, row2col3;
private JButton row3col1, row3col2, row3col3, row4col1, row4col2, row4col3;
private JButton row5col1, row5col2, row5col3, row6col1, row6col2, row6col3;
//private JButton row7col1, row7col2, row7col3;
public TicTacToe() {
// TODO Auto-generated constructor stub
frame = new JFrame("Tic-Tac-Toe");
contentPane = new JPanel();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
contentPane.setLayout(new GridLayout(10, 2, 5, 5));
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
row1col1 = new JButton();
row1col1.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row1col1);
row1col2 = new JButton();
row1col2.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row1col2);
row1col3 = new JButton();
row1col3.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row1col3);
row2col1 = new JButton();
row2col1.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row2col1);
row2col2 = new JButton();
row2col2.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row2col2);
row2col3 = new JButton();
row2col3.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row2col3);
row3col1 = new JButton();
row3col1.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row3col1);
row3col2 = new JButton();
row3col2.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row3col2);
row3col3 = new JButton();
row3col3.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row3col3);
row4col1 = new JButton();
row4col1.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row4col1);
row4col2 = new JButton();
row4col2.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row4col2);
row4col3 = new JButton();
row4col3.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row4col3);
row5col1 = new JButton();
row5col1.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row5col1);
row5col2 = new JButton();
row5col2.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row5col2);
row5col3 = new JButton();
row5col3.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row5col3);
row6col1 = new JButton();
row6col1.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row6col1);
row6col2 = new JButton();
row6col2.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row6col2);
row6col3 = new JButton();
row6col3.setMargin(new Insets(10, 10, 10, 10));
contentPane.add(row6col3);
frame.setContentPane(contentPane);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
private static void runGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
TicTacToe greeting = new TicTacToe();
}
public static void main(String[] args) {
/* Methods that create and show a GUI should be
run from an event-dispatching thread */
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
runGUI();
}
});
}
}