Hi,

I'm doing argument validation with PHP in my view. All what I need is working, but I don't know, how I can set the page title there. When I dump the $view variable, so I get a big output and I cannot search there for the right array-key to modify. Firefox and Safari are crashing, when I'm loading the page with the dump. Has anyone an idea?

Comments

dawehner’s picture

Status: Active » Fixed

To look at a view variable dpm($view) (part of the devel module) is recommended.

You could manipulate the title by setting $view->build_info['title']

merlinofchaos’s picture

You can also set, I think it's $agument->validated_title out of the validator, and that will set the title that will be used in substitutions. i.e, normally if you have a Node: Nid arg as the first argument, %1 will be replaced by the title of the node.

jepster_’s picture

Hi,

thanks for your fast reply. $view->build_info['title'] and $argument->validated_title aren't working. I've solved it by redirecting the user with php's own method:

header("Status: 301 Moved Permanently");
header("Location:https://test.not-a-domain/no-authorization");
exit;

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

planctus’s picture

I'm t trying to set the title for a page display through the argument validation...
In my situation the argument is a date field, my problem is that it is always showing a title where date granularity is 'day'.
I think it does this way since the argument settings for granularity is 'day', indeed.
But when i'm showing a "month" view that title doesn't make any sense, i've tried both method suggested here, i also changed the value for the argument granularity inside the $view object in that case using 'month', so that the title generated would reflect the change but nothing worked.
Is there any chance to do this?

jacktonkin’s picture

Set $handler->validated_title in the validator to set the argument title as described in #2 above. This works for me in 6.x-2.16.

planctus’s picture

I suppose i had already tried that solution when i wrote this...
Don't remember exactly, but what i'm using now is something like this:
$view->display['display_id']->handler->handlers['argument']['field_nameofthefield']->options['title']
That way it is working...
Thanks,
Da.