Hi! I am not good at PHP.
So, when you're looking at the thread view of ballp.it (like this page (http://ballp.it/index.php?board=12.0)), the HTML rendered, in order, for the Subject/Started By cell is...
- a useless div
- a useless span
- a link to the actual thread
- a link to the new posts in that thread (if there are any)
- Thread creator
- Thread pagination
So, in HTML terms, what I get is...
<td class="subject windowbg2">
<div>
<span id="msg_50194"><a href="http://ballp.it/index.php?topic=1703.0">First times watching classic movies</a></span>
<a href="http://ballp.it/index.php?topic=1703.msg50303#new" class="jump-to-new subject-level" id="newicon50194">
<svg viewBox="0 0 32 32"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#PostNewOnes"></use></svg>
</a>
<p>Started by <a href="http://ballp.it/index.php?action=profile;u=19" title="View the profile of jack chick">jack chick</a>
<small id="pages50194">« <a class="navPages" href="http://ballp.it/index.php?topic=1703.0">1</a> <a class="navPages" href="http://ballp.it/index.php?topic=1703.15">2</a> »</small>
</p>
</div>
</td>
While this isn't the worst thing in the world, it really isn't the best. Most importantly, I really want that "jump to new" link to come first, so I can float it appropriately. Perfect world, the markup looks like this...
<td class="subject-and-creator">
<div class="title">
<a href="http://ballp.it/index.php?topic=1703.msg50303#new" class="jump-to-new subject-level" id="newicon50194">
<svg viewBox="0 0 32 32"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#PostNewOnes"></use></svg>
</a>
<a class="thread-title" href="http://ballp.it/index.php?topic=1703.0">First times watching classic movies</a>
</div>
<div class="creator-and-pagination">
<span class="creator">
Started by <a href="http://ballp.it/index.php?action=profile;u=19" title="View the profile of jack chick">jack chick</a>
</span>
<span class="pagination">
« <a class="navPages" href="http://ballp.it/index.php?topic=1703.0">1</a> <a class="navPages" href="http://ballp.it/index.php?topic=1703.15">2</a> »
</span>
</div>
</td>
With a lot of these ballpit changes, these changes are pretty easy. However, in this particular case, the code is a fucking mess...
<td class="subject ', $alternate_class, '">
<div ', (!empty($topic['quick_mod']['modify']) ? 'id="topic_' . $topic['first_post']['id'] . '" onmouseout="mouse_on_div = 0;" onmouseover="mouse_on_div = 1;" ondblclick="modify_topic(\'' . $topic['id'] . '\', \'' . $topic['first_post']['id'] . '\');"' : ''), '>
', $topic['is_sticky'] ? '<strong>' : '', '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], (!$context['can_approve_posts'] && !$topic['approved'] ? ' <em>(' . $txt['awaiting_approval'] . ')</em>' : ''), '</span>', $topic['is_sticky'] ? '</strong>' : '';
// Is this topic new? (assuming they are logged in!)
if ($topic['new'] && $context['user']['is_logged'])
echo '
<a href="', $topic['new_href'], '" class="jump-to-new subject-level" id="newicon' . $topic['first_post']['id'] . '">
<svg viewBox="0 0 32 32" ><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#PostNewOnes"></use></svg>
</a>';
echo '
<p>', $txt['started_by'], ' ', $topic['first_post']['member']['link'], '
<small id="pages' . $topic['first_post']['id'] . '">', $topic['pages'], '</small>
</p>
</div>
</td>
If somebody has the chops and wants to simplify that crap, I'd appreciate it. If you're interested, I have all of this up in a GitHub repo (https://github.com/AhoyLemon/ballpit), the file in question here is Themes/Giggle/MessageIndex.template.php
Otherwise, no big deal, but I'll probably never address that float issue.
What messy code. So basically this?
echo "<td class='subject {$alternate_class}'>
<div class='title' ", (!empty($topic["quick_mod"]["modify"])
? "id='topic_" . $topic["first_post"]["id"] . "' onmouseout='mouse_on_div = 0;' onmouseover='mouse_on_div = 1;' ondblclick='modify_topic(\"" . $topic["id"] . "\", \"" . $topic["first_post"]["id"] . "\");'"
: ""),
">";
// Is this topic new? (assuming they are logged in!)
if ($topic["new"] && $context["user"]["is_logged"]) {
echo "
<a href='{$topic["new_href"]}' class='jump-to-new subject-level' id='newicon{$topic["first_post"]["id"]}'>
<svg viewBox='0 0 32 32' ><use xmlns:xlink='http://www.w3.org/1999/xlink' xlink:href='#PostNewOnes'></use></svg>
</a>";
}
echo ($topic["is_sticky"]
? "<strong>"
: ""),
"{$topic["first_post"]["link"]}",
(!$context["can_approve_posts"]
&& !$topic["approved"]
? " <em>({$txt["awaiting_approval"]})</em>"
: ""),
"",
($topic["is_sticky"]
? "</strong>"
: "");
echo "</div><div class='creator-and-pagination'>";
echo " <span class='creator'>
{$txt["started_by"]} {$topic["first_post"]["member"]["link"]}
</span>
<span class='pagination'>
{$topic["pages"]}
</span>
</div>
</td>";