0

I have a view set up to function as a blog, and a contextual filter set up to filter by author of the blog post.

The point is to be able to click on the blog post author link and go to a page that lists all the blog posts by that person. This is facing anyone who visits the site, and any visitor (non-logged in) can view the blog listing of any of the authors.

The current set up is to have a Relationship to the author table, and filter by User: name. Then when visiting a url /blog/author/John Smith, you see all posts by John Smith. (I realise that's an invalid URL.)


The filter itself is working and the blog posts are being pulled through for all the authors, however, I'm having issues to transform spaces to dashes and to lowercase the URL.

When you visit /blog/author/John Smith, you are redirected to /blog/author/John%20Smith, and then the blog posts by John Smith are visible, but this isn't good enough for us in terms of URLs.

So instead of /blog/author/John%20Smith, I need the URL to be /blog/author/john-smith.

The problem is that the default checkboxes and options which work for taxonomy terms do not seem to work with Author names. Ticking transform spaces to dashes in URL and using case in path: lower does not affect the filter the way I want it to - it has no effect at all.

enter image description here


I'm considering creating a new field in the user entity and then using that to filter instead. Like john-smith for the John Smith user. I'm not sure if that'll work, but I'll try it out right now.

The above has worked, and I do have the URL's I want and they query for the right items. I'm not sure if it's the cleanest solution though.

  • Why not just use the uid as an input? And create a path alias for john smith with pathauto instead? – nhck Jul 2 '18 at 11:30
  • I'm not sure what you mean. Use UID as the filter? This is a view page - I want the URL's to contain the full name of the user, and to use that value to do the filtering. Where would the UID be picked up from and how would the view make a connection that /blog/author/john-smith = UID 10, and then query all blog posts whose author has UID of 10? – user86549 Jul 2 '18 at 13:58
0

You should remove the "User: name" Relationship on the view and add a new relationship "User: uid". Then you can access the author view with /blog/author/123.

Then create a URL alias for "/blog/author/123" and set it to "/blog/author/john-smith". You will then be able to access the view with both the uid 123 or using john-smith.

  • 1
    Oh, that makes sense now, it would have taken me a while to approach it from that angle. I'll try and get it to work this way as well! – user86549 Jul 3 '18 at 14:08
  • Were you able to get it working using this approach? – Steve Mulvihill Jul 4 '18 at 2:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy