I have a Drupal 7 Views query plugin module that pulls in data from a RESTful API for use in Views. I used this series of articles as a starting point to build it: https://www.lullabot.com/articles/building-views-query-plugins. I now need to port it to Drupal 8.
I have made a start on the porting process, with the help of this series of articles: https://www.lullabot.com/articles/building-views-query-plugins-dupal-8-part-1. The Drupal 8 module now successfully pulls in data for the fields that use the 'standard' handler.
I'm currently stuck on trying to get tokens representing one of those fields to work when rewriting results.
The field is called access-url
and contains URLs. If I tick 'Override the output of this field with custom text' on that field, and enter the token form, {{ access-url }}
, it just returns '0' for every record, whereas if I untick that box it returns the URLs correctly. Meanwhile, the token form of the id
field works correctly.
(In real life I will want to use {{ access-url }}
under 'Output this field as a custom link', but 'Override the output of this field with custom text' illustrates the problem better.)
How can I get the {{ access-url }}
token to work correctly?
I expect it would be helpful if I posted some code, but I'm not sure what code would be most helpful, so please let me know.
Additional debugging info: as far as I can tell, all seems well until it gets to the line in PluginBase::viewsTokenReplace()
that runs $this->getRenderer()->renderPlain($build)
. $build
at that point has the value of access-url
in it, but the renderer returns zero.
addSelfTokens()
runs, the correct tokens are already in the$tokens
array. In fact, all seems well until it gets to the line inPluginBase::viewsTokenReplace()
that runs$this->getRenderer()->renderPlain($build)
.$build
at that point has the value ofaccess-url
in it, but the renderer returns zero. Any further thoughts on what might be going on would be gratefully received.