I want to use a view to select nodes in a content type field. This view must receive an argument that is another field of the content type.
Can someone explain me how to pass the argument from the field to the view?
Excuse my poor english
You might be able to use the Views Arguments Extras module. It will allow the argument of the view to come from a cck field. Some more details about this module (from its project page):
This module contains a group of view handlers and plugins that add the following options:
Argument Default Current Node CCK
allows for cck field values of the current node to be loaded as default arguments
Argument Default Request Params
allows for get and post params as default values
Argument Order Sort
a sort handler, that allows for the order of items to be based on their order in a multi-value argument
I believe you can use the argument validation to validate the argument, and at that point you are free to change the $handler->argument value before it is passed in to Views.
If you just want to change what the view displays based on the value of a CCK field, the easiest way I have found is to embed a view into the template using views_embed_view(). Something like this in your template file would work I think:
//Use the dsm function to print out your $node object
//to get the name of the field you want to pass as an arg
//like this: dsm($node);
//Assuming that the value of that field is in $node->cck_field['0']:
print views_embed_view('name_of_view', 'name_of_display', $node->cck_field['0'];
views_embed_view() only needs the first argument, the name of the view, to work. It will return the HTML for the default display of the named view. We pass it a specific display as a second argument. Anything after the second argument gets passed into the view as an argument, so we pass in the value of the field as an argument to the view. See this link for some documentation on how the function works.
Related
I have added leangen/graphql-spqr as described in the readme.
Before we had a custom implementation of graphql types like in customtype.types.gql.
After implementation, everything works fine, except the type which are called e.g. OperatorInput, are named in the autogenerated graphql doc like "OperatorInputInput".
I tried to Change it like this in the declaration:
#GraphQLArgument(name = "OperatorInput", description = "Required fields for Operator") OperatorInput operator
But it wasn't applied.
Do you know any workaround?
This is intended. Keep in mind that in GraphQL's type system, input and output types are strictly different. Let's say you have this in Java:
public Book saveBook(Book in) {...}
The Book that is the return type and the Book that is the argument type are 2 different types in GraphQL, and must have unique names. So Input is added automatically to make the names unique.
If you're 100% sure you want to override this, register a custom TypeInfoGenerator via GraphQLSchemaGenerator#withTypeInfoGenerator. You can inherit from DefaultTypeInfoGenerator and override generateInputTypeName. BUT! Do pay attention that if you end up producing the same name for 2 different types, all hell breaks loose. So maybe only drop the suffix Input if the classname already ends with Input and never ever use such classes for output.
Btw #GraphQLArgument sets the name of the argument, not the name of the type of the argument.
I have this piece of code:
controlDetails = this.form().design(1).addControl(FormControlType::Group, #quickCreateDetails);
controlDetails.dataSource(fbds.id());
controlDetails.dataGroup(#quickCreateDetails);
controlDetails.frameType(10);
controlDetails.autoDataGroup(true);
controlDetails.hideIfEmpty(false);
controlDetails.columns(2);
I want to modify the editability of one certain field on that dataGroup, but I don't know how to do it with code or in the AOT (DS). Seems like Im pretty much limited...
You have next options:
change Form Data Source filed editability
via AOT - https://msdn.microsoft.com/EN-US/library/aa860145.aspx
via code FormDataSource.object: InventTrans_ds.object(fieldNum(InventTrans, Qty)).allowEdit(false)
change child control design property. addControl returns FormBuildGroupControl. Then you have to loop through controlNum(), find correct design control and cast it to one of FormBuildControl nested type with data bounding. There you have allowEdit method.
I've got an object with a list defined inside it which points to a type that can be inherited. From what I understand MVC's default model binder will always instance the base type when reading data back in to this array from a form so by default I will have a list of base types.
So I need to use my own model binder and override CreateModel to instance a specific type (say from a hidden field). However when I do this and use
bindingContext.ValueProvider.GetValue("ModelType")
it always returns null even though through using fiddler I can see that form value Settings[0].ModelType contains my objects type and I need this value in CreateModel to instance the correct type.
Solved it. If your array objects need to be typed based on each item you need to use the following call to get "into" the array item
bindingContext.ValueProvider.GetValue(bindingContext.ModelName + ".ModelType")
I'm not sure if this is the standard way to do it. If anyone has any better suggestions feel free to add them
how to know the field variable name when output by views. eg:now, i want to overwrite a field's output, the name which i added is field_hello. but i don't know what's the variable name of it? namely how to print the variable in views-view-field--field_hello.tpl.php
In the Views UI, under "Basic settings", you can click "Theme: Information" to get a list of what template files are currently being used and what file names can be used. You'll find all the default templates within your views/theme/ directory. If you copy one of those to create your custom template, e.g. views-view-field.tpl.php, you'll see they're heavily documented with all the variable names available. For field templates, you have $view, $field, $row, and $output. Depending on whether you want the pre-processed value or the processed value, you probably want $field or $output.
Using Theme Developer (formerly part of Devel), you can inspect a page and see what variables get passed to it and use them in your own templates.
If you talk about using a variable inside a views field: this is not possible due to security issues. Depending on the fields, there are some variables available and Vies tells you which one but you don't have easy access to ALL the variables that your template is able to process.
The simplest solution is to look inside the views module directory, views/theme/ all of these templates are the default view display and contain code that prints the varibles, arrays etc that your view will generate.
In Drupal I am working with a view that takes a couple of arguments; the nid argument is just passes along to the next page, but the other three arguments it uses to retrieve content. The problem seems to be that the view uses all arguments to retrieve content, which obviously doesn't work since the presence of nid will always return one single row.
So how do i perform the search (retrieve the content pages) using the three arguments while leaving nid intact as it needs to be passed to another page?
If I understand correctly, the first argument is a nid, and you want that argument to have no effect on the outcome of the view (no filtering)?
If so, adjust the Validator options for the first (nid) argument.
Set Validator to PHP Code.
Leave PHP validate code blank and the argument will always be considered invalid.
Set Action to take if argument does not validate to Display all values.
This will have the effect of ignoring the first argument.