Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
aggregator-item.html.twig markup contains generic div wrapper that should be replaced with more suitable element.
Proposed resolution
Replace main wrapper element <div>
into <article>
.
Remaining tasks
- Review patch
User interface changes
None
API changes
None
Original report by @jeff-burnz
Potential use of article, header, time (with pubdate) and footer.
http://api.drupal.org/api/drupal/modules--aggregator--aggregator-item.tp...
Beta phase evaluation
Issue category | Task because item template contains outdated html semantics |
---|---|
Issue priority | Not critical because the issue is only with html semantics |
Unfrozen changes | Unfrozen because RC is markup freeze, not beta. |
Comment | File | Size | Author |
---|---|---|---|
#49 | aggergato-html-interdiff.txt | 698 bytes | mortendk |
#49 | agrregator-item-1189806-47.patch | 1.14 KB | mortendk |
#46 | after.png | 168.17 KB | DickJohnson |
#46 | before.png | 156.6 KB | DickJohnson |
#45 | agrregator-item-1189806-45.patch | 1.12 KB | mortendk |
Comments
Comment #1
cosmicdreams CreditAttribution: cosmicdreams commentedshould we approach this from the "each field in it's own container" strategy?
I don't remember which thread I was reading but the plan was suggested that we shouldn't contruct html5-based objects as follows:
but instead do this
Is my assumption correct? is this the way we modify the aggregator-term.tpl.php?
Comment #2
Jeff Burnz CreditAttribution: Jeff Burnz commentedThe second one makes no sense - the header and footer elements (if used) need to be children of the article element, as does the time element - use the first structure.
Comment #3
zachattack CreditAttribution: zachattack commentedWhat would the inclusion of the Header and Footer Tags be for?
Previously the most frustrating part of Drupal front-end development is the Tag soup that comes from over implementing things.
Because of HTML5's youth, it has the potential to be a labyrinthine system of Tags. Since some of the relationships of these new Tags can sometimes be in question, we have an opportunity here to implement clean code according to our standards.
Also your api link goes to aggregator-item.tpl.php and not aggregator-term.tpl.php. Which template are you meaning to reference?
Comment #4
Jeff Burnz CreditAttribution: Jeff Burnz commentedThe issue is for aggregator-item.tpl.php.
I agree that it could be easy to get carried away with the semantic elements just because we can - we should only use what we need.
Comment #5
JacineI think this one should mirror the current node.tpl.php as much as possible.
Comment #6
cluke009 CreditAttribution: cluke009 commentedThis seemed like a good place for me to try and help with core.
I am new to core contrib, and the html5 specs can get confusing as they are still a moving target.
I am not sure if this is the best way to accomplish what we want but it might help to at least get some discussion going here.
Comment #7
cluke009 CreditAttribution: cluke009 commentedTesting
Comment #8
cluke009 CreditAttribution: cluke009 commentedHere is a version using theme_datetime().
This corrects the datetime value using format_date() but it feels like to much php inside of a template for my liking.
Guess I will wait for feedback on this.
Comment #9
star-szrThis will need reworking now that the templates have been converted to Twig - especially the PHP inside the template, something closer to #6 would work better.
Comment #10
Dragan Eror CreditAttribution: Dragan Eror commentedLet me check this one...
Comment #11
Dragan Eror CreditAttribution: Dragan Eror commented- Improved markup to HTML5
- Also improved structure, now more looks like node structure.
Comment #12
mortendk CreditAttribution: mortendk commentedwow the code behind aggregator looks like its a loooongtime since it got some real love - loads of hardcoded variables n stuff.
Oooh well if fixed the issue with hardcode "time ago" translation & added in a variable for the date.
split up the catagories so we can do something with em in the template (instad of using implode)
Comment #13
tlattimore CreditAttribution: tlattimore commentedHere is a re-roll of #12 with whitespace cleaned up.
Comment #14
mortendk CreditAttribution: mortendk commentedare we gonna have any class on this - think it should follow the same naming as a node (but be easy to clean out)
we should be able to make a "X days ago" formating ?
probably a preprocess
Comment #15
mortendk CreditAttribution: mortendk commentedthe categories data wasnt correct thats fixed now
Comment #16
Jeff Burnz CreditAttribution: Jeff Burnz commentedWhy the change to a numeric array? I think its easier to work with an associative array, e.g. unset one key etc.
Shouldn't this be {{ attributes.class }} {{ attributes }} etc, can we assume only class attributes?
h3?
Theres some extra lines at the bottom of template_preprocess_aggregator_item() also.
Comment #17
mortendk CreditAttribution: mortendk commented* Why the change to a numeric array?
cause i like to be able to not have the twig vars look like this: {{ foo[key].title }}
Good call with the h3 & attributes
Comment #18
rteijeiro CreditAttribution: rteijeiro commentedRemoved some whitespaces in previous patch.
Comment #19
joelpittetSome nitpicky coding standards review:
This variable should be called posted_time to match closer to what it's coming form.
Remove the space before the comma.
Needs the space around the period.
Formatted should be Sentence case and N should be capitalized. The sentence should end in a period.
Sentences should start with Caps.
Remove this newline.
Do we need this div anymore?
Theses needs spaces before and after the insides of the {{ }} and indented one more.
Comment #20
Dragan Eror CreditAttribution: Dragan Eror commentedWill take over to make these changes...
Comment #21
Dragan Eror CreditAttribution: Dragan Eror commentedPatch rerolled, changes are made...
Comment #22
joelpittet@Dragan Eror, Did it need a re-roll? I don't see any of the changes from #19 in that patch.
Also this is probably a good opportunity to point out that we likely need to extend Twig's date format to use named formats from drupal.
This will likely need a separate issue and if someone's interested in creating it I'll help where I can to make this happen.
This should read like:
<time datetime="{{ createdtime|date_format("medium") }}">
Note date_format filter doesn't exist in twig. Or we some how merge date filter with date_format but that could get buggy/hacky quick...Comment #24
Dragan Eror CreditAttribution: Dragan Eror commented@joelpittet don't need to re-roll. Only change I didn't make is that one with the date. Didn't want to make variable changes just because "nicer" name because now follows same name as node.html.twig.
Comment #25
lauriiiReroll
Comment #26
joelpittetThanks for the reroll @lauriii.
This doesn't seem to be there or being used, may have came from a reroll.
addClass() ftw:)
Comment #27
lauriiiUps, forgot to change variable used in the twig file.
addClass()
ftw ;)Comment #30
jussil CreditAttribution: jussil commentedComment #31
jussil CreditAttribution: jussil commentedA lot have happened in short amount of time regarding this little template. Basically there are 2 different issues that have already modified this template and it's data alot.
This whole issue needs an re-evaluation on if there is work needed to be done when compared to current situation? So current patch is not really valid anymore.
Comment #32
lauriiiI think we could still add the time and change the main element to article
Comment #33
jussil CreditAttribution: jussil commentedThis patch only contains the div -> article change. How about classy?
And posted_time is not needed right now, as there already is "Posted on" field which uses created timestamp.
Comment #34
mortendk CreditAttribution: mortendk commentedclassy is done in a seperate issue to not make epic patches - keep em small & clean :)
Comment #35
jussil CreditAttribution: jussil commentedHere is a patch with classy changes. So if we don't want to fix the classy in this issue, I can create patch into separate issue.
Comment #36
lauriiiLets set the issue for "Needs review" so the testbot triggers
Comment #37
lauriiiWe could update the issue summary and add the beta evaluation table.
Comment #38
jussil CreditAttribution: jussil commentedComment #39
jussil CreditAttribution: jussil commentedIssue summary is now updated with beta evaluation table.
Comment #40
lauriiiComment #41
jussil CreditAttribution: jussil commentedComment #42
mortendk CreditAttribution: mortendk commentedcool lets use the right wrappers +1 for article
Comment #43
alexpottThe template has moved.
Comment #44
alexpottAlso shouldn't we also change the template in the aggregator module?
Comment #45
mortendk CreditAttribution: mortendk commentedUpdated tha patch to both fix in core & in class
made sure we didnt forget the {{ attributes }} in the wrapper
Comment #46
DickJohnson CreditAttribution: DickJohnson commentedTested the patch. It does what it's supposed to do.
Before
After
I'm not completely sure about the coding standards on twig, but it looks like there's few extra empty lines on rows 25 and 27. Didn't find similar scenario from documentation, but didn't find empty lines either.
Comment #47
DickJohnson CreditAttribution: DickJohnson commentedComment #48
joelpittetIt's not something we are explicit about in the standards @see https://www.drupal.org/node/1823416 though by convention we usually don't put those in. They could be removed or not, not too much of a concern. Would be more of a concern if it was double new lines or not 2 spaces.
Thanks for the manual testing @DickJohnson
Comment #49
mortendk CreditAttribution: mortendk commentedwhen i read the twig documentation then we have to remove the white space
so hereby done with an interdiff
Comment #50
mortendk CreditAttribution: mortendk commentedComment #51
joelpittetAlso good:)
Comment #53
joelpittetRandom testbot failure (maybe not random they are deploying a change today)
Comment #55
alexpottTemplates are not just frozen. Committed b631c16 and pushed to 8.0.x. Thanks!