Simple Machines Community Forum

Customizing SMF => Graphics and Templates => Aiheen aloitti: Biology Forums - toukokuu 26, 2011, 01:58:25 IP

Otsikko: Removing Re in Boardindex.template.php
Kirjoitti: Biology Forums - toukokuu 26, 2011, 01:58:25 IP
Using 1.1.13, how do I remove that re: etcetc... I just want the title without the Re...

Otsikko: Re: Removing Re in Boardindex.template.php
Kirjoitti: MrGrumpy - toukokuu 26, 2011, 02:20:11 IP
Easy way to do it is to edit the text string for it, I can't tell you exactly what to edit as I don't use 1.1.13 but you need to look in index.english.php and search for

'Re: ';

In 2.0 it the text string looks like

$txt['response_prefix'] = 'Re: ';

It will probably be a bit different in your version but the Re: part will be the same

Change the

'Re: ';

To

' ';





Otsikko: Re: Removing Re in Boardindex.template.php
Kirjoitti: Sir Osis of Liver - toukokuu 26, 2011, 04:17:33 IP

No, that won't work.  The 'Re:' is included in the variable $board['last_post']['link'].  Have to find where that variable is put together.

Otsikko: Re: Removing Re in Boardindex.template.php
Kirjoitti: Sir Osis of Liver - toukokuu 26, 2011, 05:03:24 IP
Ok, here's a workaround -

In BoardIndex.template.php

Find this:



/* The board's and children's 'last_post's have:
time, timestamp (a number that represents the time.), id (of the post), topic (topic id.),
link, href, subject, start (where they should go for the first unread post.),
and member. (which has id, name, link, href, username in it.) */
if (!empty($board['last_post']['id']))
echo '
<b>', $txt[22], '</b>  ', $txt[525], ' ', $board['last_post']['member']['link'] , '<br />
', $txt['smf88'], ' ', $board['last_post']['link'], '<br />
', $txt[30], ' ', $board['last_post']['time'];




Change it to this:



/* The board's and children's 'last_post's have:
time, timestamp (a number that represents the time.), id (of the post), topic (topic id.),
link, href, subject, start (where they should go for the first unread post.),
and member. (which has id, name, link, href, username in it.) */
if (!empty($board['last_post']['id']))

$board['last_post']['link'] = str_replace('Re: ', '', $board['last_post']['link']);

echo '
<b>', $txt[22], '</b>  ', $txt[525], ' ', $board['last_post']['member']['link'] , '<br />
', $txt['smf88'], ' ', $board['last_post']['link'], '<br />
', $txt[30], ' ', $board['last_post']['time'];



(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.thekrashsite.com%2Fpics%2Ffacepalm.gif&hash=eb6eaaf6d758386f3994677fedcb1367d2d9387f)

Otsikko: Re: Removing Re in Boardindex.template.php
Kirjoitti: Biology Forums - toukokuu 26, 2011, 05:53:20 IP
krash, Worked like a Charm, thankS! Thanks to everyone else too!
Otsikko: Re: Removing Re in Boardindex.template.php
Kirjoitti: Matthew K. - toukokuu 26, 2011, 05:56:45 IP
Actually, a str_replace(); isn't the smartest move in this case. A preg_replace(); is the best option for this case since "Re:" could be used in other positions beyond the start of the string.

I do believe there are multiple mods for this...
Otsikko: Re: Removing Re in Boardindex.template.php
Kirjoitti: Sir Osis of Liver - toukokuu 26, 2011, 11:19:20 IP
Lainaus käyttäjältä: Labradoodle-360 - toukokuu 26, 2011, 05:56:45 IP
Actually, a str_replace(); isn't the smartest move in this case. A preg_replace(); is the best option for this case since "Re:" could be used in other positions beyond the start of the string.

Thought of that after I got off.  Can't make preg_replace do what I want.  This should work, but doesn't.


$board['last_post']['link'] = preg_replace('/Re: /', '', $board['last_post']['link'], 1);


With no limit parameter, or limit = -1, it replaces all occurences of 'Re: '.  With limit = 1, it doesn't replace any.

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.thekrashsite.com%2Fpics%2Fidk.gif&hash=9ac7acf13f4cfaa1b58390444a38dea11e5473d2)