When theming a page, PHPTemplate (and possibly others) offer suggestions based on the uri. This is a handy feature but when dealing with arguments that are integers, either you have to theme the previous suggestion or the specific one eg.
page-user.tpl.php or page-user-1.tpl.php
this is a bit cumbersome because I want to theme all the user profile pages but to do that I have to override page-user.tpl.php but then faced with the problem that the user login page now is themed as well.
What this patch do is provide a wildcard for integer arguments like page-user-*.tpl.php. Suggestions which have additional arguments like page-user-edit.tpl.php remain the same; this simply differentiates the suggestions with and without integer args.
Comments
Comment #1
evil_marty CreditAttribution: evil_marty commentedMy apologies, ignore the asterix in the file, I forgot that that character is illigal in the most filesystems, I've updated it to the tild ~ character.
Comment #2
Crell CreditAttribution: Crell commentedDrupal 5 is no longer taking new features. Drupal 6 is currently frozen for refinement, so it's unlikely that this will get in. Moving to the Drupal-7 queue.
That said, it sounds like interesting functionality.
Comment #3
dvessel CreditAttribution: dvessel commentedDefinitely a neat idea and it wouldn't break anything in 6. ;)
Comment #4
deekayen CreditAttribution: deekayen commentedSame patch ported to the new D7 location.
Comment #6
deekayen CreditAttribution: deekayen commentedUpdates tests that failed for recognizing the new wildcard options being returned.
Comment #8
deekayen CreditAttribution: deekayen commentedUpdating for failed tests.
Comment #9
moshe weitzman CreditAttribution: moshe weitzman commentedSeems like a no-brainer to me. Well done. Lets wait for a healthy test bot to check this. If it does not reset status, we are good.
Comment #10
deekayen CreditAttribution: deekayen commentedI know I shouldn't touch it, but I couldn't help but add the following inline docs:
Comment #12
deekayen CreditAttribution: deekayen commentedI think this is from a bad patch that got committed.
Comment #13
deekayen CreditAttribution: deekayen commentedmoshe had it rtbc
Comment #14
webchickThis is interesting! Tagging for themer review to get a pair or two of affected pair of eyes on this, although dvessel has already given it a thumbs-up above.
To me, the ~ and - are very difficult to distinguish visually. I understand why asterisks can't be used, but I wonder if we could use a different character. Is there by chance a character in CSS/HTML/JS other than * that would be synonymous with "stuff here"? Maybe % because that's a wildcard in SQL?
Comment #15
deekayen CreditAttribution: deekayen commentedAssuming it keeps support for strangely old filesystems, the DOS 8.3 spec says the character limits are:
That means the % would be a valid alternative, however going all the way back to Windows 3.1.1, filenames that exceeded the 8 character limit were shortened by replacing characters with the tilde as the wildcard, so it's not as if it's without historic continuity:
It's not just Windows 3.x either. When Windows 2000 shares files to other old-ish machines, it shortens the filename with a tilde.
http://technet.microsoft.com/en-us/library/cc938923.aspx
I don't know what OS or filesystem commonly shortens filenames with %.
Disclaimer: I haven't developed Drupal on Windows in years.
Comment #16
Damien Tournoud CreditAttribution: Damien Tournoud commentedIt makes sense to use "%". Let's do that ;)
Comment #17
stephthegeek CreditAttribution: stephthegeek commentedClever! Big thumbs up.
Ditto with the %. -~ is too awkward.
Comment #18
deekayen CreditAttribution: deekayen commentedHere's a % version.
Comment #19
Manuel Garcia CreditAttribution: Manuel Garcia commentedA very nice innitiative!
I'm more of a themer myself, so forgive me if this is nonsense from a developer point of view. My comment is about the wildcard character, thinking about usability, would it be possible to have the wildcard be 'all' instead of a '%' ? so we could use tpls like page-user-all.tpl.php.
I think it would be best understood and immediately grasped by the themers, but again, no clue if this is even a possibility - either way, i hope this gets in for d7 =))
Comment #20
deekayen CreditAttribution: deekayen commentedTechnically it's possible to have all instead, but then you couldn't have any paths with "all" in them that wouldn't confuse the wildcard. Having the patch /page/user/all would confuse the rule.
Comment #21
Manuel Garcia CreditAttribution: Manuel Garcia commentedah, excelent point... nevermind =)
Comment #22
ultimateboy CreditAttribution: ultimateboy commentedAlthough I don't really think it will be used all that often, there is a definite use case and this solves it quite nicely. From a themer's perspective, I like the implementation.
Comment #23
deekayen CreditAttribution: deekayen commentedIn anticipation of the commit, here's some documentation for http://drupal.org/update/theme/6/7
Nav link:
Body:
Comment #24
Zarabadoo CreditAttribution: Zarabadoo commentedI am also in favor of this.
Comment #25
Zarabadoo CreditAttribution: Zarabadoo commentedI really need to remember to full page refresh before I comment on something. Status fixed.
Comment #26
webchickWow, nice patch AND docs in advance? I'm in love. ;)
Hm. I was going to commit this but I got:
patching file includes/theme.inc
patching file modules/simpletest/tests/theme.test
patch unexpectedly ends in middle of line
Hunk #1 succeeded at 27 with fuzz 1.
Could someone do a quick re-roll please?
Comment #27
deekayen CreditAttribution: deekayen commentedMinty fresh.
Comment #28
webchickAwesome, thanks! :)
Committed to HEAD. If someone could stick those nice docs into the theme upgrade guide that'd be lovely!
Comment #29
deekayen CreditAttribution: deekayen commenteddocs saved from #23
Comment #30
mattyoung CreditAttribution: mattyoung commentedsubscribe
Comment #32
Shane Birley CreditAttribution: Shane Birley commentedDoes this latest patch work on D6? Or was it D7 only?
Comment #33
deekayen CreditAttribution: deekayen commentedIt probably doesn't apply exactly, but since it was originally written for 5.2, I bet you could add it to 6.x.
Comment #34
Shane Birley CreditAttribution: Shane Birley commentedCool. I will take a gander at the code and see if it would be quick to port.
Comment #35
sign CreditAttribution: sign commentedseemed like the docs were a bit outdated, so did a small edit to http://drupal.org/node/254940
page-user-%.tpl.php --> page--user--%.tpl.php
page-user-edit.tpl.php --> page--user--edit.tpl.php