Skip to main content
21 events
when toggle format what by license comment
Jul 12, 2013 at 14:35 comment added Mołot @therobyouknow DO NOT SERIAL UPVOTE ME! And honestly, upvotes on this post earned me 2x more rep than acceptance would, so no need to worry ;) After all I asked Jimajamma to post his comment as an answer, right? And I was fighting to prove his way is easier :P So it should be obvious I don't mind his post to be accepted.
Jul 12, 2013 at 14:32 comment added therobyouknow Thanks Mołot (+1) and Jimajamma - this has now started to appear and I'll experiment further to confirm - I think something is a bit 'flakey' with my setup as these did not show before. If all's well I would like to accept Jimajamma's answer (thanks Mołot - I'll upvote all your posts...)
Jul 12, 2013 at 14:09 comment added Mołot @therobyouknow i.sstatic.net/e5X2y.png D7 supports this too, just tested it. Dunno why it does not work for you. Jimajamma's answer is OK if arguments are in contextual filters. At least works for me. (LOL 'm fighting against my answer being accepted)
Jul 12, 2013 at 14:07 comment added therobyouknow Clive yes seems like this is the case, sadly. So Mołot's answer would likely be the accepted one once I try it out and if successful. Though apparently this may have been considered in the past and discounted on the grounds of security - Mołot welcome your further thoughts on this when you can. Thanks everyone so far. Most appreciated.
Jul 12, 2013 at 14:03 comment added Clive Yep might well be that, I didn't really use Views in Drupal 6 so I can't help there I'm afraid
Jul 12, 2013 at 14:02 comment added therobyouknow @Clive yes, that format_string() is worth knowing - it's like a kind of printf() in the C language but I think it is rather that Jimajamma's answer is assuming that such notations !1 and !2 in rewrite results in views in D6 have been carried forward into D7, as he explains in his edited answer. As format_string() shows, !2 is inserting the value of the variable 2 as is but that variable has to be defined in the first place, i.e. for my case, this variable 2 would be the arg2 of the URL.
Jul 12, 2013 at 13:52 comment added Clive @therobyouknow Did you read the format_string() docs I linked to?
Jul 12, 2013 at 13:48 comment added therobyouknow Clive, to be exact, ! as in exclamation mark character followed directly by the numeral 2 i.e. !2 not percentage character followed by numeral 2 i.e. %2. I'm really scratching my head on this one, what did Jimajamma mean (please come back and advise) also Mołot concurs with using !2 etc. Mołot do you know what Jimajamma meant by using !2 ?!
Jul 12, 2013 at 13:46 comment added Clive @Mołot You're right you've disclaimed that pretty well - I just breezed through the code :)
Jul 12, 2013 at 13:45 comment added Clive @therobyouknow Sorry no, I've only ever used/seen %1 etc for Views placeholders. Bearing in mind the various formats format_string() provides, though, it kind of makes sense. Though (hypothetically) the ! would pass the string through unsanitized which might not be desirable
Jul 12, 2013 at 13:43 comment added Mołot @Clive I meant it as an outline, hence "It's meant to set you on the right track, but you need to apply your own sanity before deploying it." - but feel free to edit my code and add that check too. I admit at the moment I don't have time to rewrite it :( Will try to remember and do it tomorrow, if you will not.
Jul 12, 2013 at 13:41 comment added therobyouknow Clive thanks for your input I will bear that in mind. By the way, are you familar with using !2 and !3 notation in rewrite results to obtain URL arguments for the output of a field in a View? I've never seen this before and tried Jimajamma's suggestion above but I just get !2 output itself as a string!
Jul 12, 2013 at 13:38 comment added Clive Just nit-picking, but you should really switch ($name) inside the foreach loop in hook_tokens(); as it is, even if you define several token types in the _info() hook, they'll all be subject to exactly the same replacement logic
Jul 12, 2013 at 13:26 comment added therobyouknow Thanks also for your input Jimajamma - but I'm not sure if I have used your !2 etc. suggestion correctly - the string !2 gets output directly from my View - see my comments (and screenshots below your answer)
Jul 12, 2013 at 12:42 history edited Mołot CC BY-SA 3.0
added 72 characters in body
Jul 12, 2013 at 12:35 comment added Mołot @Jimajamma my mistake - I assumed it's not about that. Blindness to the obvious. If you'll post it as an answer I'll gladly upvote.
Jul 12, 2013 at 12:34 comment added Jimajamma if arg2 and arg3 are actually arguments or contextual filters for the View in question, you should be able to just use !2, !3 in the rewrite (I am ignoring arg1 as that really can't easily be dynamic)
Jul 12, 2013 at 12:34 comment added Mołot @therobyouknow tokens from $_GET are costly and messes with cache, afaik. And see my updated answer before you'll try.
Jul 12, 2013 at 12:33 history edited Mołot CC BY-SA 3.0
added 582 characters in body
Jul 12, 2013 at 12:31 comment added therobyouknow +1 thank you very much @Mołot So, had this feature been considered for views by the developers involved, in the past and decided against? It is likely I will accept your answer, I'll give the code you gave a try.
Jul 12, 2013 at 12:26 history answered Mołot CC BY-SA 3.0