I am using the quicktab module and at some tabs I pass in a view (to which I added some arguments).
I tried setting the arguments (which are 2 booleans) to 1/0 and it doesn't work, it displays all the values instead of filtering it. If I use the view in a block and set the arguments there to 1/0 it filters them properly.
Am I doing something wrong? Or does this feature not work with the quicktabs?
I recently did the same, but instead of using the arguments of quicktabs, I used the arguments in views. Together with the context module, that suited for me. Hope this helps you :-)
Related
I like a lot of the built in features the built-in DataSet designer provides in VS2010 and do not want to have to change to something entirely different if at all possible. The problem is, to have optional parameters, I need to create completely independent functions for each combination of parameters. So for 6 parameters, I would need 63 different functions. That's obviously completely unmanageable.
Is there a way to have one function which ONLY adds a parameter to the generated WHERE clause of my SQL if it has a value, and otherwise, it ignores it?
You could add these optional paremeters into the WHERE-Clause with ISNULL:
WHERE (YourTable.Column = ISNULL(#Column, YourTable.Column))
On this way the SQL works with or without the (optional) parameter. If the value is null it won't affect the result.
You only have to add all parameters into the DataAdapter's parameter-collection(the optional with AllowDbNull=true). But i'm fairly sure that they will be automatically added correctly.
There are fields in my view that I would rather hide depending on the value of another field. I am lookinf for ways to do it in code, or otherwise but without enabling php filter.
I don't know which version of Views you use. I can't quite remember whether output rewriting was available in V2, but I suppose it was. In V3, it's there, waiting for you to use it.
Output rewriting accepts any HTML code and you can use replacements from what the query returned. I'm not sure you can use PHP there, perhaps you can, but I've never really tried. Anyways, let's say you have field_foo and field_bar, and that both are some select options or checkboxes or some other multiple choice thing, having key-value pairs in the database (like 1|foo, 2|bar etc.).
In this situation, you should have four options available:
[field_foo_value]
[field_foo_value_raw]
[field_bar_value]
[field_bar_value_raw]
(they'll probably be named a bit differently, I can't quite remember the exact naming convention). You can rewrite the "bar" field output like this:
<span class="visibility-[field_foo_value_raw]">[field_bar_value]</span>
Then, assuming the possible keys for "foo" are 1 and 2, you can write some CSS:
span.visibility-1 { display: inline; }
span.visibility-2 { display: none; }
If PHP is allowed, it should be even easier, but I have a feeling you can only use HTML. Anyway, I hope this helps.
Using hook_form_alter or hook_form_FORM_ID_alter you can alter the views_exposed_form form. From there, it should be possible to use CTools' Dependent to set visibility dependencies between fields. Views's exposed form layout is partially handled in the theme layer (see views-exposed-form.tpl.php) so more work is probably needed to hide/show the labels.
This module seams like it would do what you need. I've used it and it's easy to setup and quick to use.
http://drupal.org/project/conditional_fields
I'm currently using Drupal Views 2 to build custom views. This works fine so far, if there wasn't a feature needed: One should be able to filter the results by different fields via URL, in the form of:
http://domain/node/M/[key]:[value],[key2]:[value2],...,[keyN]:[valueN]
The key names are fixed and may not be altered.
I tried hooking hook_views_query_alter() and hook_views_pre_render() to generalize this for all views, evaluating the given filterset, but to no satisfying end, as i could not get hold of the query used to build the view (I could not alter it in the proper way, as i do not know the field names in the query).
The question is, if there is a nicer way to implement such a filterset.
thanks in advance,
flo
Looking at the comments you seem to want not only url arguments but url arguments in a custom format.
I would firstly urge you to drop your format and use the standard views argument format, this will be more standards compliant and save you a lot of headache.
If you want to use that paticular format you are going to have to write some custom code in a module.
Register a callback using hook_menu().
In that callback use arg() and decode your arguments.
Pass the arguments to views_embed_view(). as shown here
I have a Panel page, which I have given a path of: books/travel-books/%city/%country/%page. The help text underneath the field says "The URL path to get to this page. You may create named placeholders for variable parts of the path by using %name for required elements and !name for optional elements. For example: "node/%node/foo", "forum/%forum" or "dashboard/!input". These named placeholders can be turned into contexts on the arguments form.", so I have named my arguments appropriately.
So now in my code, I need to get the values of those arguments. I've seen arg(0), but that requires me knowing which index the argument has. Is there anyway to access it by the name I gave it in the path? Something like arg('city')??
The reason being, that I need to have similar path arguments on many pages, and need to access the values of these in my module. But the arguments may be in different places for another page. For instance, another page might be at: flights/%city/%country. Then I want to access the city argument within the same function, but it is at a different index.
Can anyone help?
you can check for arg(0) first, see whether it is 'books', 'flights', whatever... then associate names accordingly. do it as a helper function in a custom module and call it before referencing (wherever you're referencing it).
The text that you quoted from the panels help text is referring to what panels call context.
Panels
Panels has a great use if you want to aware of what context a certain piece of content is being viewed. Fx if you had several shops with different products, you might want to control which blocks in a sidebar would be displayed, based on the shop that the product belonged to.
This is essential what context is in panels and what the named placeholdes are used for. You can be default add different kinds of context, fx nodes, users, taxonomy terms. You can then use the different pieces of context if various ways.
If panels default options is not enough, you can also create your own plugins to panels to make it handle your special cases. But it requires a lot of time to learn how panels work.
Other solutions
Using panels might not be the easiest option for you, it depends what you are aiming for. But if you don't need to make pages that is aware of the context, this would probably be a lot easier to do with views and theming. Views can handle arguments in urls very well, and it is a lot simpler to both style and configure.
In Drupal 7 you can get the arguments from hook_content_type_render
function <your plugin name>_content_type_render($subtype, $conf, $panel_args, $context) {
$block = new StdClass;
$block->title = t('test');
$block->content = 'test panel arg: '.$panel_args[0];
return $block;
}
Custom panel tutorial
Anyone knows how to pass multiple arguments from Panels into a view in Drupal 6?
Edit: I know how to pass one argument from Panels into Views, but not multiple arguments.
In the panels argument field, separate them with a "/"
Something like arg1/arg2/arg3
The main thing is to save your view as a panel pane. Good instructions here
In your tutorial you use site.ru/% path for panel, so this means that you use the variable % as argument. If you write site.ru/%1/%2, you can use two argument's variable %1 and %2.