Currently Theme Developer inserts spans to do its magic. Although it works, it causes some problems: #777246: User permissions page is broken #1031080: Value for '- None -' in term reference field is not rendered #1102766: Theme developer breaks views grouping #1084202: Interferes with date_repeat #1044870: Theme developer breaks drupal_set_message #775574: Theme Developer changes views, Grouping field title repeats #1025380: Admin module's menu doesn't work
So people are requesting ways to easily disable theme developer or enable it only for some users: #699020: Option to disable devel_themer for user 1 #1185920: disable themer for admin interface? #1088176: Stop it from admin pages #767462: add an options to switch off the themer #321352: Theme Developer per User
A possible solution is to use comments #425716: Use comments instead of spans to markup theme calls
Alternatively we could insert spans (or divs) smartly and reuse existing html as much as possible. This is the approach i've taken and i've attached a small proof of concept patch that will limit the use of spans as much as possible. It will look to see if the resulting html of a hook has a 'root tag'. e.g: <div>Hi everyone.. other html here</div>. In this case it will add the thmr attribute directly to the div. If a root element isn't found it falls back to the original span-method.
P.S. The comments approach looks like a great approach to solving this issue. But i only just came across it when writing this. I'm going to look into it when i have some spare time.
| Comment | File | Size | Author |
|---|---|---|---|
| #34 | devel_themer-Fix-html-simplehtmldom-1247280-32.patch | 5.04 KB | beanluc |
| #22 | html_fix_simplehtmldom.patch | 4.51 KB | kenneth.venken |
| #15 | html_fix_combined.patch | 5.75 KB | kenneth.venken |
| #14 | html_fix_bugs.patch | 915 bytes | kenneth.venken |
| #11 | html_fix_revised.patch | 5.68 KB | kenneth.venken |
Comments
Comment #1
kenneth.venken commentedOk, so it seems that the comments solution still needs some work to support outlines and parent elements.
I've improved my method and it should be ready to be used. It supports outlines and parent elements.
Every hook returns some sort of html. Master branch just wraps this html in span tags. This causes some layouts to break because it conflicts with the css selectors and possible span css defined in the theme. My method parses the html and adds thmr keys to the top level elements.
For example, lets say a hook returns:
This code contains three top level elements; The H2, p and the text "Just some text".
What my method does, is insert the thmr="thmr_#" attribute to the two top level tags and will wrap the text element in a span. So the result would be
As you can see, insertion of spans is kept to an absolute minimum. Most of all, it won't interfere with existing css selectors. I've also added some span css to devel_themer to make sure the inserted spans are always display:inline so the layout isn't changed.
Feel free to improve the code however you want.
Comment #2
kenneth.venken commentedThe previous patch still contains some debugging code. Use this patch
Comment #3
kenneth.venken commentedComment #4
kenneth.venken commentedComment #5
kenneth.venken commentedComment #6
kenneth.venken commentedi just fixed bugs #1129526: "template called" does not mention the page template and #1031080: Value for '- None -' in term reference field is not rendered. They are also present in this code, so here's a patch without them.
Comment #7
khiminrm commentedSubscribe
Comment #8
afeijo#2 works!! You saved me :)
Comment #9
kenneth.venken commentedOk, so one final adjustment. It is possible that two different thmr attributes are added to the same tag. These patches will fix that and will merge the keys into one thmr attribute: e.g:
I've added two patches, one without the extra bugfixes as described in #6, one with.
Comment #10
effulgentsia commentedThanks, Kenneth. I really appreciate you stepping in and giving this module some love. Some feedback about the smaller patch in #9:
Firstly, check out http://drupal.org/project/dreditor. If you install that, you get "Review" buttons (well, links that look like buttons) appearing next to patches on d.o. issue comments, that when you click, opens a neat patch review tool. One of the things it does is highlight in red any whitespace that doesn't conform to Drupal coding standards (e.g., tabs instead of spaces and trailing whitespace). You have several of those in the patch. Please fix them.
I think this is overkill, and maybe best left to follow-up issues as specific use-cases come up. I wonder if we could just start with a single class ("devel-themer-wrapper" ?), which would already be better than what the module has currently, and then see where that's insufficient.
I didn't review the implementation in detail yet. Is there no existing GPL implementation of this functionality that we can use rather than something custom? Maybe there isn't, but if there is, I think it would be good to leverage something that's already been thoroughly tested and is being maintained.
Can you give some examples of when this happens (any examples from core only, or only with certain contrib modules/themes)? I'd like to make sure people can test these situations in different browsers, and share their results.
I'd also like to see more feedback here from others (@afeijo: thanks for yours, but can you state what browser(s) you tried this on), so I asked for that in #425716-15: Use comments instead of spans to markup theme calls.
Comment #11
kenneth.venken commentedSo i installed dreditor and tidied up my patch. I also rebased it against the current version.
It probably is. Changed it in the new patch.
I did a quick google search and found some implementations (html5lib, PHP Document Object Model,...) but didn't find a simple one that can handle html fragments. Using an existing library, we would still need to write code that adds the keys only to toplevel elements. We would get the parsing of html to a tree for free but that's currently about 20 loc. And how many bugs can there be in 20 loc :).
The rss icon on the localhost/node page for example (bartik theme). It has an a-wrapper that will get two thmr keys assigned to it.
Comment #12
lucascaro commentedjust fyi, I got this error:
# patch < html_fix_revised_0.patch
patching file devel_themer.css
patching file devel_themer.js
patching file devel_themer.module
Hunk #2 FAILED at 318.
Hunk #3 succeeded at 372 (offset -10 lines).
1 out of 3 hunks FAILED -- saving rejects to file devel_themer.module.rej
Comment #13
kenneth.venken commentedNo problems here. I've tested it with the latest version and the patch applies fine:
Either
or
will do.
Comment #14
kenneth.venken commentedIt seems at least two. Patch attached, should be applied after #11.
Comment #15
kenneth.venken commentedThis patch combines the patches in #11 and #14.
Comment #16
kenneth.venken commentedThis patch fixes #1299086: devel_themer breaks theme menu and #1287278: Problem using context module when devel_themer is active
Comment #17
tribsel commented#16 worked for me, thanks
Comment #18
Fidelix commented#15 Worked for me on the context module page.
Comment #19
matglas86 commentedIt works great. Way better than it was.
Comment #20
dr0bz commented#15 is not working with the current version:
patching file devel_themer.css
patching file devel_themer.module
Hunk #2 FAILED at 317.
Hunk #3 succeeded at 393 (offset 11 lines).
1 out of 3 hunks FAILED -- saving rejects to file devel_themer.module.rej
I'm trying this patch to get vertical tabs working according to this issue.
Could you look into it?
Comment #21
lucascaro commentedawesome!
devel_themer 7.x-1.x-dev does not work out of the box (with my zen child theme) but using this patch (#15) it does so I think this should get into dev as soon as possible.
thanks!
Comment #22
kenneth.venken commentedImproved version. The simplehtmldom module (http://drupal.org/project/simplehtmldom) is used to insert the markers.
Comment #23
n4rc1ssus commentedI've tried all the patches in succession and when the pop-up dialog opens it still pushes everything off of the shortcut bar (hidden or not). The buttons themselves still work but with my theme's background color you can't even see them to find them unless you happen to hover over them.
Comment #24
beanluc commentedRTBC for me. Module works exactly as expected, with the patch from #22, in several different themes, including core, contrib and custom ones.
Comment #25
beanluc commented"Minor" would be the appropriate status for an issue describing the effects *after* n4rc1ssus applied the patch (see #23), but, the impact without the patch at all is still major. That's the appropriate status for the current issue.
Comment #26
jrsinclair commentedI've tested #22 and it makes the module usable again. Thank you.
Comment #27
knalstaaf commentedIs there a final patch that does all of the above?
I've applied some now (started with the last one) but things still aren't working for me. The toggle div doesn't even appear in the code (
themer-toggle).It does work if the Views Slideshow is disabled though.
Comment #28
beanluc commentedPatch #22 should be all you need.
Comment #29
knalstaaf commentedThat's the very first one I had applied, to no avail (from which I started applying the earlier ones).
I disabled the slideshow for a while and got what I needed.
Comment #30
beanluc commentedI'm not involved with the development, maintenance or support of this module, but, it almost certainly would be of help to those who are if you were to describe what "doesn't work" looks like.
Does nothing at all?
Yields broken website?
Generates error messages?
Isn't installable?
Something else?
Under what conditions: With core themes, contrib themes or your custom theme?
For what it's worth, I also use Views Slideshow, and didn't have a problem.
Comment #31
knalstaaf commentedThe only thing that's happening, or not happening, is the checkbox appearing on the left bottom. It's there in the admin theme (Seven), but not in the custom theme (Omega theme).
Other modules being actively used on those pages: Language switcher dropdown, Featured content.
Comment #32
itaine commented#22 needs to be re-rolled. Its no longer applies cleanly to 7-x-1.x-dev.
Comment #33
beanluc commentedNeeds work, according to #32.
Comment #34
beanluc commentedComment #35
kenneth.venken commentedI've commit the patch in #34 to 7.x-1.x.
I feel confident it will improve the useability of theme developer although it probably needs more real world testing.
Comment #36
itaine commentedGetting the following after trying to pull down drush dl devel_themer:
File devel_themer-7.x-1.x-dev.tar.gz is corrupt (wrong md5 checksum).
However, pulled down nicely via git clone, but after enabling I get a http error 500.
Comment #37
kenneth.venken commentedI can't reproduce your problems. I can download with drush dl devel_themer after which drush en devel_themer will correctly download and enable the simplehtmldom module.
I've also manually verified the md5 checksum:
Could you perhaps post the output of your drush commands or try to manually download, verify checksum and enable the module? Make sure to also install the simplehtmldom module.
Comment #38
itaine commentedWorks like a charm! Don't know what went wrong the first time around.
Comment #39.0
(not verified) commentedmore info about new method
Comment #40
held69 commentedUsing latest (dev) version but i am still not seeing a theme info checkbox.
tested on:
bartik
garland
corporate clean
finally got this to work with 7.x-1.12 simplehtmldom instead of 7.x-2.0/7.x-2.x-dev