Patch #3 in my series of Drupal-markup-spaghetti-core fixes, addresses the pager, found on the bottom of every page that has multiple pages.
or other meanlingless markup
- improves themability through semantic markup and more accessible CSS classes
- adds a title link to each pager link, accessibility improvement
- adds visual aids to first, previous, next, and last links ... this dramatically increases usability, and cleans up the clutter with pager links (this falls in line with the most common trends with pagination, see Google, Digg, etc..)
- renamed attributes to parameters so that HTML attributes could be added to each themable function
- cleans up pager code a bit
Tested and looking great! I must say, I don't *dread* looking at pager links at the bottom anymore, they look visually more appealing (no more weird spacing breaks either) and I know underneath the code isn't a mess!
Stay tuned for patch #4...
Comments
Comment #1
m3avrck commentedOh forgot to add, by using this improved markup structure, themers should have a much *easier* time, as they won't have to override all of these Drupal theme functions just to clean them up. They'll be looking pretty "sexy" by default now ;-)
Comment #2
m3avrck commentedOops, let's have this set to review just in case.
Comment #3
drummI think we should keep <strong>, but add that class.
Comment #4
m3avrck commentedI added the
font-weight: boldfor that class to the CSS. However, that is a good point, instead of just a meaningless<span>a<strong>would be better. I'll reroll the patch in a bit.Comment #5
m3avrck commentedupdated patch keeping
<strong>in there now but withpager-currentclass, more semantic than<span>.Comment #6
chx commentedComment #7
dries commented- renamed attributes to parameters so that HTML attributes could be added to each themable function
I don't understand this change.
Is the HTML that much better/smaller? Is it possible to post before and after HTML code?
Comment #8
m3avrck commentedDries, the renaming was to be consistent with core. To add the appropriate titles to each pager link, I needed to pass in an $attributes('title' => 'title goes here'), however because of the way the functions were setup, they were already using the name $attibutes, which I thought was odd. Generally in core it seems anytime you encounter $attributes it is for $attributes on some sort of HTML markup, whether it be a link, table, form, etc... I can revert this change if you want, but do you have a name I can use that *isn't* $attributes then so I can pass in the HTML attributes?
Attached is a screen shot, before and after, note how much cleaner it looks and how much easier it is, usability wise.
As for the code, here is before:
And after:
Note how much cleaner the code is, not extraneous
If you are wondering about all of the class="active", look at this bug: http://drupal.org/node/44502
Comment #9
dries commentedLooks good indeed. Committed to HEAD. Thanks.
Comment #10
Steven commentedThis code introduces possible HTML issues because the pager title is no longer escaped. If someone changes the text to ">>" or "<<" (which is not inconceivable) there will be broken HTML.
The reason seems to be the unnecessary and ugly use of HTML entities. We should use literal characters instead. It makes the code more readable, and avoids hacks like:
$attributes['title'] = is_numeric($text) ? 'goto page ' . $text : 'goto ' . str_replace(array('« ', '‹ ', ' ›', ' »'), '', $text) . ' page';Finally, the text 'goto page' is not translatable. Shouldn't it be "go to" anyhow?
Comment #11
m3avrck commentedSteven, great catch! Yes, I always seem to forget that Drupal is UTF-8 so we can use literals, I do like that change very much! And the catch on the titles was very good too, completely slipped my mind.
As for the 'goto' verse 'go to', I actually debated this myself. Here in America I see it used both ways all the time, not sure if there is the *real* proper way or not, so let's go with what you have and keep it seperate.
RTC!
Comment #12
dries commentedFeel free to commit.
Comment #13
Steven commentedCommitted to HEAD.
Comment #14
(not verified) commented