V
V
Vadim Timoshenko2015-02-18 13:55:59
Drupal
Vadim Timoshenko, 2015-02-18 13:55:59

How to correctly set up contextual filters views in drupal?

There is a node with a field created using the user reference module . Those. when creating a node, I enter in the field the name of a user already registered in the system.
The user, when entering the site, on the main page, receives a list (block) that forms views. A list of those same nodes, with a field created using the user reference module.
The task is to display in this block only those nodes that belong to the user who views them.
Those. "Vasily Petrovich" enters the site, and there is a list for him on the main page. And for others, this list is invisible.
Thanks for the hints.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
T
Timofey, 2015-02-18
@PbI6A_KuT

You need to use context filters. You press add, select the node field with a link to the user, in the "If the filter value is not in the URL" block, select "Pass the default value", in the "Logged in user ID" drop-down list (I don't know how in non-localized views, but I think figure it out). Should earn.

4
4X_Pro, 2017-10-25
@lexa_lashak

This is actually not an error, but a warning related to the fact that the $argv array is defined only when you run it from the command line, and you run the script through the Web server. Nevertheless, the code, in theory, fulfills normally.
To get rid of it, you need to add an additional check:
And I can’t help but notice: doing an include of a file whose name came from outside (from a GET request) without any checks is, in general, a very serious security hole.

V
Vyacheslav, 2017-10-25
@Firik67

$argv - Contains an array of all arguments passed to the script when run from the command line.
php.net/manual/en/reserved.variables.argv.php

L
Lander, 2017-10-25
@usdglander

$argv - only used via cli. Are you sure you're running the script from the command line?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question