I'm running in a problem where I want to use a token to create a link in a view:

<a href="/here/[name]">[name]</a>

I have an example on this page (look at the list of categories under the AddThis button): http://snapwebsites.info/directory

My problem is that [name] is capitalized and may include spaces. What I'd like is a function that makes the whole thing lowercase and replaces spaces with dashes. Something like this would work, I would think:

[name:lowercase():spaces-to-dashes()]

Would you accept a patch for something like this?

I guess we can look in a different syntax too, but this looks like what you already support. The idea would be that the () mean that the name represents a function to be called with the token. I suppose we could let users supply some static parameters too (obviously, providing another token would be even better... but that's getting a bit complicated!)

Thank you for looking into this and for your answers.
Alexis

Comments

Dave Reid’s picture

Status: Active » Closed (won't fix)

It's not really possible at all with the current API. You'd have to make different tokens for each use that you need.

nithinkolekar’s picture

Issue summary: View changes

Any possibilities now ? Was thinking in same way instead creating new thread just wanna reopen this topic.

Just like [random:hash:?], more functional token can be implemented using pipe symbol

[node:title]|titlecase|prefix[Mr.]
ex. if title is stanley brown then it should be converted to

Stanley Brown - 1st function
Mr. Stanley Brown - 2nd function

nithinkolekar’s picture

Version: 6.x-1.x-dev » 7.x-1.5
Priority: Minor » Normal
Status: Closed (won't fix) » Active