Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: wynnyelle - joulukuu 19, 2013, 09:40:18 IP

Otsikko: Keeping post titles from spilling over on 2nd line on recent posts block
Kirjoitti: wynnyelle - joulukuu 19, 2013, 09:40:18 IP
I am attaching a screenshot with the problem titles circled in red so you see what I mean. What I want to do is prevent spill-over, either by shortening the board names, the post subject names, or, probably, both.

Is there an easy way to do this? I was thinking it would be shortened by the use of the ellipses. Just putting a "..." at the end of a certain number of characters to indicate there's more, but there's no room for it on this page.

Otsikko: Re: Keeping post titles from spilling over on 2nd line on recent posts block
Kirjoitti: margarett - joulukuu 20, 2013, 08:02:46 AP
I'm not sure, but it won't be easy... The list of recent topics is built using dt/dd tags and their size is automatic depending on the resolution.
I guess it would require to transform that into a table.
Otsikko: Re: Keeping post titles from spilling over on 2nd line on recent posts block
Kirjoitti: Kays - joulukuu 20, 2013, 10:02:44 AP
Hi, in looking at this it's not really that difficult to do. ;)

In Subs-Recent.php in the Sources directory, look for:


'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#msg' . $row['id_msg'] . '" rel="nofollow">' . $row['subject'] . '</a>'


And replace it with:


'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#msg' . $row['id_msg'] . '" rel="nofollow" title="' . $row['subject'] . '">' . shorten_subject($row['subject'], 15) . '</a>'


It's currently set at 15 characters. If that's either too much or too little, adjust the 15 at the end of that line according.

I've also added a title attribute so the complete subject name is shown if the user mouses over the link.

If that's not sufficient, this also could be done with the board names. However I would suggest that you try decreasing the font size a wee bit first. :)

As usual, do back up that file before making any changes to it.