drupal views 样式ServiceViews做

views_get_view | views.module | Views 7 | Drupal APIDrupal中views的用法
Posted 星期六, 02/07/2009 - 12:57 by qiqiy
在drupal中使用views模块会上瘾的!我说的是真的。
以前在drupal中从来不用views,都是自已写sql语句查询,然后根据设计页面,达到想要的效果。不用views的原因是设置太烦,我看见一大堆参数就头痛,不愿意花时间来仔细研究每个参数的具体用法,这几天在drupal.org上试着读了几篇views的教程,然后一步步实验了一下,此后,用views大有一发不可收拾之势。
下面,把我所体会到的一点Views用法概括一下.
这是一张views页面的截图,左边的Defaults一项,是设置views的类型的,你可以设一page类型(可以通过URL访问),block类型(可以出现在block设置页面,你随便放哪里)。还有feed,attachment,这二个我没有用过,大概是用来做RSS和把多个views合在一起的。
basic settings
basic settings就不说了,一看都知道是用来做什么的,不过有一点Theme:Information我想很重要。点击它,会列出这个views用到的所有pages,根据这些信息,你可以在自已的theme中创建所需的page,然后自定义页面的布局,这一点在定制开发中将非常有用。
page settins
如果views是page类型,用出现这个page settings项,在这里你可以设置这个页面的path和menu,这个也非常简单
Relationships
这里可以设置相关联的项,比如Comment: User,可以设置显示某一个用户或当前用户的comment.还有Taxonomy: Parent term,如果在Taxonomy中有父子相关的项,这里就可以设置相应的显示了。
我想这是最重要的一项了,参数。在这里,可以动态改变views的内容。这里有点像URL中的?后面的参数。
上面是argument的一张图。其中的wildcard是通配符,就是显示所有项的RUL,比如我要显示用户为3的所有comment,如果我在views中path设为comment,我就可以通过http://localhost/comment/3方式来访问,而如果要访问所有comment,如果这里的wildcard设为all,就可以http://localhost/comment/all,如果wildcard设为*,则可以通过http://localhost/comment/*来访问所有的comment.在这里有一个很有用的选项,就是默认的参数,provide default argument.在 action to take if argument is not present这一项的最下面。
当URL中没有参数传来时,这里可以设置一个默认的值。比如第一项,fixed entry,你可以输入一个固定的值,也可以用PHP code动态的产生。
sort就是按照什么规则排序,很简单
Filters也挺重要的。这个就是views的一个过滤器,想要什么,不要什么,都可以通过这里来实现。比如你要node类型为article的,可以Type=article方式来实现。如果你的drupal是多国语言,那这个选项是一定要用到的,通过filters,可以在切换不同语言的时候显示不同的语言列表,关于多国语言,接下来会有一个专门的说明。
OK,view的设置就这么简单,你只需要通过鼠标点几下就可以实现大部分的功能了,接下来的事情就交给美工来调整页面了,再也不用像以前那样手写sql语句了,通过views实现列表迅速而不容易出错,那么,你还有什么理由不用views呢
本文永久地址:
, 转载请注明出处.
請問版主,可以在views裡面的theme直接使用jqery嗎?
因為我想由views篩選出所想要的資料流
然後套入到jqery的函數庫內
可是我一直沒辦法成功秀出效果
当然可以啊,用drupal_add_js把你要用的js文件加进来就可以了
嗯,谢谢你的关注,其实views用起来也挺简单的,主要是反复的试验,然后再体会其中的用法,如有问题,欢迎发帖询问..
站长要是再详细一点,就更好了!
Copyright 鲁ICP备号drupalServiceViews做_百度知道
drupalServiceViews做
使用drupal做一个moblie商场项目,用什么方法,和插件更合适这种项目。
可以有专业的 公司代理的 传感器(英文名称:transducer/sensor)是一种检测装置,能感受到被测量的信息,并能将感受到的信息,按一定规律变换成为电信号或其他所需形式的信息输出,以满足信息的传输、处理、存储、显示、记录和控制等要求。传感器的特点包括:微型化、数字化、智能化、多功能化、系统化、网络化。它是实现自动检测和自动控制的首要环节。传感器的存在和发展,让物体有了触觉、味觉和嗅觉等感官,让物体慢慢变得活了起来。通常根据其基本感知功能分为热敏元件、光敏元件、气敏元件、力敏元件、磁敏元件、湿敏元件、声敏元件、放射线敏感元件、色敏元件和味敏元件等十大类。
来自团队:
其他类似问题
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.
I have a View with an exposed form . I am trying to a few things on it. Ideally I would like to have a dropdown that fires the form with no button. If that is not possible then I would like to have the button text something different than apply.
I hacked it for now and change views_form in views.module but that does not seem like the right way to do it. I only have one exposed form right now, but what if I add more?
Please see
for my example.
I am poking around drupal.org and seeing others with the same problem but no solutions so far. Not sure where the best place to get Drupal help is.
Here is the change I made so far:
function views_exposed_form(&$form_state) {
// Make sure that we validate because this form might be submitted
// multiple times per page.
$form_state['must_validate'] = TRUE;
$view = &$form_state['view'];
$display = &$form_state['display'];
$form_state['input'] = $view-&get_exposed_input();
// Let form plugins know this is for exposed widgets.
$form_state['exposed'] = TRUE;
$form['#info'] = array();
if (!variable_get('clean_url', FALSE)) {
$form['q'] = array(
'#type' =& 'hidden',
'#value' =& $view-&get_url(),
// Go through each filter and let it generate its info.
foreach ($view-&filter as $id =& $filter) {
$view-&filter[$id]-&exposed_form($form, $form_state);
if ($info = $view-&filter[$id]-&exposed_info()) {
$form['#info']['filter-' . $id] = $
// I CHANGED The VALUE OF THIS SUBMIT BUTTON TO GO
$form['submit'] = array(
'#name' =& '', // prevent from showing up in $_GET.
'#type' =& 'submit',
'#value' =& t('go'),
$form['#action'] = url($view-&get_url());
$form['#theme'] = views_theme_functions('views_exposed_form', $view, $display);
$form['#id'] = views_css_safe('views_exposed_form-' . check_plain($view-&name) . '-' . check_plain($display-&id));
$form['#attributes']['class'] = array('views-exposed-form');
// If using AJAX, we need the form plugin.
if ($view-&use_ajax) {
drupal_add_js('misc/jquery.form.js');
views_add_js('dependent');
11.6k2276100
11.7k39101134
If you want the drop-down to fire, I'd use JavaScript instead of hacking the module as Eaton suggests.
Basically, you can modify the text with hook_form_alter as Eaton suggests, then use in the same hook_form_alter, add a call to drupal_add_js with your custom JS which hides the button and submits the form on the onChange handler of the select drop-down.
You want that submit button there for those 10% of users for whom the JS fails.
Or, you could use a preprocess function to alter the form even before it is build. I wanted to change the text on the button, so I did this:
function MYTHEME_preprocess_views_exposed_form(&$vars, $hook) {
// only alter the jobs search exposed filter form
if ($vars['form']['#id'] == 'views-exposed-form-jobs-search-page-1') {
// Change the text on the submit button
$vars['form']['submit']['#value'] = t('Search');
// Rebuild the rendered version (submit button, rest remains unchanged)
unset($vars['form']['submit']['#printed']);
$vars['button'] = drupal_render($vars['form']['submit']);
Tom Kirkpatrick
Both of the above are fine but I found out that altering the form might not always lead to desirable results, mainly because exposed filters are themed using a specifc theme template. The proper way of changing the theme would be to override the views-exposed-form.tpl file in your theme's folder. Bear in mind that this will apply to all exposed filter forms, to theme a specific one, you will need to use a different name for that filename, like:
views-exposed-form--TITLE--DISPLAY.tpl.php
views-exposed-form--TITLE.tpl.php
and some others, you can check the Theme: Information section of your views for template naming conventions.
This module provides an auto-submit among other things
This module is great to improving exposed filters
1,49521427
You should be able to use hook_form_alter() () to change the form as it's built, modifying the fields in question when that particular view is being displayed. You can nuke the submit button, add a #theme function that calls the drupal_add_js() function, and so on.
As long as the GET params come in the way views expect them, everything will work fine -- it was designed that way to allow bookmarking of pages with exposed filter settings, etc. The important part is to make sure you're doing the form mangling in your own module's hook_form_alter() function, so that it won't make other views driven stuff choke.
6,70021822
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled

我要回帖

更多关于 drupal views操作 的文章

 

随机推荐