MyBB Community Forums

Full Version: how can I comment out parts of a template?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Currently postbit_author_user contains the following:

{$lang->postbit_posts} {$post['postnum']}<br />
	{$lang->postbit_joined} {$post['userregdate']}
	{$post['replink']}{$post['warninglevel']}

I want to remove the warninglevel from the postbit but I don't want to delete it out of the template, I just want to comment it out in the template. I tried PHP and HTML comments and it just didn't work. Probably user error on my part but still, if anyone can point me in the right direction I would much appreciate it.

Thanks in advance!
TBH I'm not really 100% sure what "commenting out" means, but to stop the warning level showing you can use this

{$lang->postbit_posts} {$post['postnum']}<br />
    {$lang->postbit_joined} {$post['userregdate']}
    {$post['replink']}<div style="display:none;">{$post['warninglevel']}</div>
If you use the Template Conditionals plugin, you can do this:
<if false then>
This is never shown!
</if>

Otherwise, something like this may do it good enough:
<!--{\$post['replink']}{\$post['warninglevel']}-->
@YoshiOlly commenting out means that the statement is left in the template but it is not processed, it's like a code comment. The display:none is a decent work around but ultimately the warninglevel is still processed by the server just not shown to the client. I don't want it to run on the server but I also don't want to delete it from the template because who knows, I may need it later at some point.

@Omar G. The conditional is also a good suggestion but also needs to be evaluated by the server, not sure how much load that would place on the server.

Here is what did not work so far:
<!--{$post['warninglevel']}-->
<!--{\$post['warninglevel']}-->
\*{$post['warninglevel']}*\

I didn't think it would be that hard to just include a comment into a template. Maybe I will just go ahead and delete the warninglevel variable from the template and be done with it.
Even if you delete it, it stills will be processed as it currently does.
(2012-08-31, 02:37 AM)Omar G. Wrote: [ -> ]Even if you delete it, it stills will be processed as it currently does.
Yeah but there won't be a query for it on each pageview anymore, right?
Everything will be as always except that the HTML will not be visible to the end user.

If you want the query (no sure if there is really a query for this) to be gone you will need to edit the core for it.
That helps, thanks. I will just remove it from the postbit and be done with it then.