Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Is the HTML/metadata for the question date wrong?

+1 vote
asked Jul 21, 2011 in Q2A Core by Scott
edited Apr 30, 2012 by Scott

On questions, where it shows the date there is a span element with a time (assuming it's UTC format). But there is nothing inside the element and the actual date ("1 week ago" etc) is outside it. Here's a sample:

<span class="qa-q-view-when">
  <span class="qa-q-view-when-data">
    <span class="published">
      <span class="value-title" title="2011-07-12T18:10:37+0000"></span>
      1 week
  <span class="qa-q-view-when-pad"> ago</span>

Also, do we really need so many HTML tags for just 3 words? Why not something like the below? EDIT: better example containing all the classes:

<span class="qa-q-view-when published">
    <span class="qa-q-view-when-data value-title" title="2011-07-12T18:10:37+0000">1 week</span>
    <span class="qa-q-view-when-pad"> ago</span>

Wouldn't that be better? Here you get to keep all the microformats while trimming useless HTML tags, and fixing the bug with the exact time not appearing when hovering the 'fuzzy time'.

However, I'm not 100% sure if it's possible to have the 'published' class only on the 'qa-q-view-when' tag, since that part is generated in one generic function (it seems to add published to the 'qa-q-view-when-data' tag as well).

Q2A version: 1.5.1

2 Answers

0 votes
answered Jul 24, 2011 by gidgreen

It's due to the incorporation of microformats information into the question page, while also applying the -data and -pad CSS class pattern used in many other places.

If this stuff is annoying, you can remove it by setting 'microformats' => false in the array in qa_post_html_defaults(...) in qa-app-options.php.

commented Jul 25, 2011 by Scott
But doesn't my example cover everything? Apart from `-data` which you could add to the `published` span. Then you have all the appropriate classes without the 4 nested levels of tags.
commented Apr 28, 2012 by Scott
Just coming back to this now. I've updated my question with a better solution, do you think that would work better?
0 votes
answered May 2, 2012 by gidgreen

[response to the updated question]

It would be possible to do this, but it would mean mixing more of the part of Q2A that generates the microformats into that part of the theme class that generates the -data and -pad tags. At the moment these are completely separated.