1

I have a view where I'm showing all postings by post author. Right now, I show (and filter) the posts by author name using contextual filters.

I want to change it so that I still use the username in the contextual filter, but when I override the the title, I want to show the human readable name.

So, for example,

www.example.com/postings/kyle.keiper

Currently shows

Postings by kyle.keiper

in the title.

How can I change the view so that the URL stays the same, but it shows "Postings by Kyle Keiper"?

4
  • In this case, is it true that "kyle.keiper" is the username of the author? And might there be another user on your site named "John Smith" and another named "janedoe? Do you currently have any controls over the username creation process?
    – Shai
    Nov 7, 2014 at 16:22
  • Is the "Postings by kyle.keiper" output in a views row or is it actually the page title (the <h1> tag of the page and <title> tag of the page)? Nov 7, 2014 at 17:13
  • @shai - "kyle.keiper" is the username of the author. Usernames are unique and it's possible for there to be multiple authors (users). Nov 10, 2014 at 13:52
  • @CaptainPants - the "Posting by kyle.keiper" is in the Views Title; it gets overridden by the contextual filter so that it shows the right username. Nov 10, 2014 at 13:53

1 Answer 1

0

You need to rewrite the output of the field and use PHP for the text string manipulations.

Two modules can help you do that. Note that you'll likely choose one of these two modules. they aren't dependent on each other. They can both help you get what you want in different ways.

  1. Views PHP
  2. Computed Field

You might need to turn the title off and create it instead in the View header using "Global: text" and turning tokens on their. The token for username (which is "[name]" will use the value from the written output you've used when defining the field.

2
  • Umm, neither of those link to the respective projects. I had to Google those modules to get the right downloads. Nov 11, 2014 at 18:39
  • Sorry about that. I fixed the links. Did you have any success?
    – Shai
    Nov 11, 2014 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.