News:

Wondering if this will always be free?  See why free is better.

Main Menu

How to remove "Re:" text from forum index only?

Started by Wellwisher, August 12, 2016, 05:59:03 AM

Previous topic - Next topic

Wellwisher

Hello devs and community got two questions today:

1. How do you remove "Re:" text from forum index page only?

And say:

2. If i wanted to replace "Re:" with "+" symbol on index also, how can i achieve this?


Kindred

you would need to be more specific

Where, specifically, on the forum index page, are you asking to replace the re:?

However...
I don't think tat you can do it, since the re: is added directly into the post title in the database.
You would have to read out the string and replace the text inline -- that has the potential to choke up your site, especially on the forum index page.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

margarett

A printscreen with some notes would help us to "visualize" what you want to do ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Wellwisher

#3
Quote from: Kindred on August 12, 2016, 08:27:48 AM
You would have to read out the string and replace the text inline -- that has the potential to choke up your site, especially on the forum index page.

@Kindred Yaw, that's why I thought I would ask some pros for some clever workarounds on the matter. I don't want to slow down the site by string replaces.

Quote from: margarett on August 12, 2016, 11:23:52 AM
A printscreen with some notes would help us to "visualize" what you want to do ;)

@margarett 1. My bad base gods should have done this screenie in the first place, so this is what i mean; all the red circles with "Re:" text, I wish to remove completely:



2. I am also thinking, can "Re: " text on front page of the forum be replaced with a simple "+" symbol to "SEXYIFY" things and make it look neater?


Illori

as kindred says it is part of the subject of each message, it is stored in the database. it is not that easy to change and may increase the time to load the page.

Arantor

There isn't a clever solution, only the one that will work which is performing string replaces. This is doubly complex because the routine that does the front board index also does the board listing for sub boards too.

Though if that's not an issue, it's a one line str_replace if you only use one language. If you use multiple languages all bets are off.

nend

Just use first_subject in place of last_subject or ['first_post']['subject'] in place of ['last_post']['subject'] in the templates. This may not be available in all areas though. ;)

margarett

It's not *that* hard to do and the load increase depends on your site usage. If it's heavily used, you might want to think twice.

Anyway, here goes nothing.
The last post bit is shown via BoardIndex.template.php but it's actually a link so it's more complicated to handle. So, it's best to go to Sources/Subs-BoardIndex.php.
There you find this:
// Prepare the subject, and make sure it's not too long.
censorText($row_board['subject']);
$row_board['short_subject'] = shorten_subject($row_board['subject'], 24);

You just need to check if the first 4 chars of $row_board is the string "Re: "
You can do that with string search functions. You could also use preg_replace but I don't how how to do that :P
// Prepare the subject, and make sure it's not too long.
censorText($row_board['subject']);
$row_board['short_subject'] = shorten_subject($row_board['subject'], 24);
$check = strpos($row_board['short_subject'], 'Re: ');
if ($check !== false) // string was found
{
if ($check == 0) // string was found it the first position, it's OK to replace
$row_board['short_subject'] = substr($row_board['short_subject'], 4); // Start on the 4th character
}

If you want a "plus" sign, then
// Prepare the subject, and make sure it's not too long.
censorText($row_board['subject']);
$row_board['short_subject'] = shorten_subject($row_board['subject'], 24);
$check = strpos($row_board['short_subject'], 'Re: ');
if ($check !== false) // string was found
{
if ($check == 0) // string was found it the first position, it's OK to replace
$row_board['short_subject'] = '+ ' . substr($row_board['short_subject'], 4); // Start on the 4th character
}


edit: ninja'd
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Wellwisher

Quote from: margarett on August 12, 2016, 05:41:13 PM
There you find this:



// Prepare the subject, and make sure it's not too long.
censorText($row_board['subject']);
$row_board['short_subject'] = shorten_subject($row_board['subject'], 24);




@margarett Thank you for the reply. In my Sources/Subs-BoardIndex.php file, the snippet of code above^ looks like this:

Thus i have no idea where to put your code in here somewhere. :P:


// Prepare the subject, and make sure it's not too long.
censorText($row_board['subject']);
$this_last_post = array(
'id' => $row_board['id_msg'],
'time' => $row_board['poster_time'] > 0 ? timeformat($row_board['poster_time']) : $txt['not_applicable'],
'timestamp' => forum_time(true, $row_board['poster_time']),
'subject' => $row_board['subject'],
'member' => array(
'id' => $row_board['id_member'],
'username' => $row_board['poster_name'] != '' ? $row_board['poster_name'] : $txt['not_applicable'],
'name' => $row_board['real_name'],
'href' => $row_board['poster_name'] != '' && !empty($row_board['id_member']) ? $scripturl . '?action=profile;u=' . $row_board['id_member'] : '',
'link' => $row_board['poster_name'] != '' ? (!empty($row_board['id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row_board['id_member'] . '">' . $row_board['real_name'] . '</a>' : $row_board['real_name']) : $txt['not_applicable'],
),
'start' => 'msg' . $row_board['new_from'],
'topic' => $row_board['id_topic']
);


Wellwisher

Quote from: nend on August 12, 2016, 05:37:29 PM
Just use first_subject in place of last_subject or ['first_post']['subject'] in place of ['last_post']['subject'] in the templates. This may not be available in all areas though. ;)

@nend This is also interesting, now that's some clever work around alright. Nice one mate.  :P The only draw back i have with this method is we have some large threads so members change the subject fields often, otherwise this would be awesome.  :P

Another way I can think of is using JS and doing a HTML search and replace so all the "computing power" will be then shifted to users-end which is a positive. But something bothers me about making such edits using js after the html has been pooped out by the server. 

Wellwisher

For the moment, I implemented a little JS. Just stick this script before the closing </body> tag. Makes a nice difference.  8)
Could even target the element and do an "onLoad" element for speedy change but for the time being this will do.  :P Thanks folks for your input and codes.



<script>
document.body.innerHTML = document.body.innerHTML.replace(/Re: /g, \'+ \');
</script>


Advertisement: