I have a view with 1 page display and 1 attachment display.
The attachment uses the sole argument: "Global:Null" overriding the default.
If the argument returns true, I'd like the attachment to show. Otherwise, I'd like it not to show.
Here's what I've done:
In the argument form, I left the title and breadcrumb fields empty.
I checked "Action to take if argument is not present: Provide default argument"
"Default argument type:PHP Code"
"Validator: PHP Code"
I notice there's a text field with no label above the textarea where I entered the php.
Do I need to enter something in this field?
I've tried the following various arguments, all which should return a boolean value, but the attachment won't show on the view.
if (empty($_GET['page'])) {
return true;
}else{
return false;
}
and this...
$showattachment = getenv("REQUEST_URI");
if (!strpos($showattachment, "page=")){
return true;
}
return false;
and:
$showattachment = getenv("REQUEST_URI");
return (preg_match("page=",$showattachment));;
I just want the attachment (five special results) to show on the first page of the results, but not on subsequent pages (?page=1,?page=2, etc.).
What am I missing here?
Comments
Comment #1
boblangdon commentedFixed.
I found a good solution was to add this right to my "views-view.tpl.php" template:
Although I still don't understand views arguments syntax.
8^/
Comment #2
esmerel commentedPoster solved own issue.
Comment #3
sagesolutions commentedFor Drupal 8.2
You can make a module with the following