I am displaying some view blocks on a page. The content is being filtered by passing the nid from the url into some custom php. I wish to change the block title to use a field from the node in question. Is this possible?
For Views 3 , the given answers are partially incorrect. Tokens are allowed in the header area of view blocks. The only tokens available are for the fields used in the view. So you can set the field that will be used only for its token to hide.
You have to select the Global: Text area option in Header, check Use replacement tokens from the first row and select the token from the Replacement Patterns dropdown.
In the current version of Views (3.14), you can write tokens in the view title.
It doesn't say so in any help messages, but I have tested it on https://simplytest.me and it worked.
You can see the available token names by selecting the last field and activating
Rewrite the output of this field and folding out
This is not possible because views doesn't allow you to used tokens.
That being said it is technically achievable. When you say you pass the nid into some custom php. What do you mean? Does the view use the nid as an argument? or are you returning something else.
The real question is are you actually filtering the content by the field? If you happend to be passing in the nid, doing a node load, then filtering on that field then this is indeed possible. I'm just guessing this is what you're doing. I might be wrong.
If you happend to actually be filtering by the field, then when you edit the argument you will see there's an option to override the title. You should be able to use %1 or %2 depending which argument is the field value.
Note I'm making a lot of assumptions on this answer. So again, this is only possible if the value you're actually filtering on is the field.
I understand that each views returns a single node displayed in a block and you want to change the title of this block. You could easily do this with a tricky trick :).
- Build your view with all the fields you need, don't put it a title
- Select the node title field and select "rewrite output", put the field token in the textarea with
- Don't put a title to your block with
Normally with this you should see your block with the title of the node returning by your view styled like a block title due to the presence of the
<h2>, a little more CSS to polish and you're done.