Easiest way to find a line of code in the templates to modify it

It’s been a while since I modified any code on forums, but I’ve been there, done that.

Using the developers window (see image below) I am wanting to remove the second "<a>, “postby” field that displays the users name.

My question: How do “you” search the templates php code to find that section of code to remove/add text or variables?

I have tried “postby”, “lastpost”, " by ". And still have not found that line of code. I have looked at multiple different templates, but have focused mostly on index.template.php.

So, how do you search the code to find that “one elusive line of code”? :slight_smile:

You can try adding some JavaScript at the top of the file (or modify the footer, I think that would be easier).

<script>
document.querySelectorAll('.lastpost').forEach(e => { e.remove(); });
// This removes the item. Chance e.remove(); to e.style.display = 'none'; to hide it instead.
</script>
5 Likes

Your example, while “ingenious”, would not remove the " by " text. I will remember that script though! Unless the text " by " is embedded in the variable?

My question really is “How do you find the elusive line of code in the templates”?

The " by " text has to be in the code somewhere. I could remove the text and by_variable.

Yes it would. It would remove everything in the red bracket below.

2 Likes

Okay. Sort of?

Since the class=“lastpost” is the css formatting string and all of the text and variable code below that class, there must be somewhere where I can format the php code.

How do I find the php code in the php templates? I have tried using the browsers +F (Windows: +F) and it does not find " by " or anything else that is findable in that text section.

I just need to remove: " by " . lastpost[lastpostname]. (made up a variable name…)

Thanks for your help, Mate! :slight_smile:

Do you need to remove it from the server or from the client? Removing it from the client would be tricky since there is no element other than .postby to find “by”. However, removing it from the server would be a bad idea because you might break something. All things aside, why do you want to remove the “by …”

4 Likes

I understand now. Thanks YT_Xaos for that reply.

In older phpBB forums all the code was present allowing you to format different sections down to the actual output. So, the formatting for this forum is stored in the dBase and not really touchable by the admins from a code standpoint.

The reason to change it: The " by " username takes up to much room to even read what the posts subject says. The “post by” name is kind of meaningless. What the post is about is much more important.

Thanks, Dudes!

6 Likes

Thanks for pointing me too that file, OxyDac! I’ll have a “look-see”.

2 Likes

You should have stated right away that you are using the SMF forum
it would be easier for other users (I had to find that information from your previous topics - the domain)
because when you mentioned phpBB here, I automatically thought that you are using that forum engine…

That’s why you should be careful how you make questions or comments so as not to lead someone in the wrong direction :joy:

NP and YW

There are TWO modes, as far as I can see, that you can use (probably in their options - maybe dashboard) you have the possibility to configure what will be displayed.

Or maybe there is a theme that will place the elements in layout according to your wishes,
but be sure to dig through the support forum there - maybe there are newer solutions (not something from 2014…)

4 Likes

Sorry about not mention SMF. And my domain, for that matter. It won’t happen again!

The BoardIndex.template.php is the location where that code resides. That user name that created the post, that I want to remove, is built somewhere else, or is in the database. And, I’m, done. :slight_smile: There is other battles to win that are more important than that.

Thanks for your help, all!

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.