MyBB Hacks

Full Version: PHP in Templates / Complex Templates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
I'm not sure how you managed to get that to show up.
It may have helped if you posted a full template too, but it doesn't look like header_welcomeblock_moderator is the problem.  Open up your global.php file and look at line 527 - what template is referred to there?

If you could post up the full template it would be helpful.  It's likely something to do with <if> tags.
I did check that, it's the header template:

PHP Code:
<script>
function blankit() {
    document.getElementById("search_box").value="";
}
function unblankit() {
    var doc = document.getElementById("search_box").value;
    if (doc == "") {
    document.getElementById("search_box").value="Enter a Search Term, then press Enter";
    }
}
</script>
<div class="menu">
	<br />
			<div id="panel">
				{$welcomeblock}
			</div>
</div>
<div id="container">
		<a name="top" id="top"></a>
		<div id="header">
			<br />
			<div class="logo"><a href="{$mybb->settings['bburl']}/index.php"><img src="http://i1081.photobucket.com/albums/j348/Seabody/seabtechlogo.png" class="logo" border="0" alt="Seabody Technologies" style="padding:0px;" /></a></div>
			<div id="search">
                                <form method="post" action="{$mybb->settings['bburl']}/search.php" style="float:right;">
                                        <input type="text" id="search_box" name="keywords" style="width:325px;" value="Enter a Search Term, then press Enter" onfocus="blankit()" onblur="unblankit()">
                                        <input type="hidden" value="do_search" name="action">
                                 </form>
                        </div>
                        <hr class="hidden" />
		</div>
		<hr class="hidden" />
		<br class="clear" />
		<div id="content">
			{$pm_notice}
			{$bannedwarning}
			{$bbclosedwarning}
			{$unreadreports}
			{$pending_joinrequests}
			<br />
			<if THIS_SCRIPT != 'index.php'><navigation><else></if><br />


I figured it was the <else> clause, so I removed it and the error vanished - but the entire header vanished.

WTF? I removed the entire <if> clause, and the board functionality resumed. I mean, the header appeared, and the navigation didn't appear on the index.

Did a bit of poking and I had that same <if> clause located within the nav template. So I assume that PHP in Templates (likely) doesn't support nested PHP, is this correct?

PHP Code:
<if THIS_SCRIPT != 'index.php'>


Shouldn't be as follows?

PHP Code:
<if THIS_SCRIPT != 'index.php' then>


I think you can remove the <else> part lke this:

PHP Code:
<if !(THIS_SCRIPT == 'index.php') then><navigation></if>

(01-06-2013 11:23 AM)Sama34 Wrote: [ -> ]

PHP Code:
<if THIS_SCRIPT != 'index.php'>


Shouldn't be as follows?

PHP Code:
<if THIS_SCRIPT != 'index.php' then>


I think you can remove the <else> part lke this:

PHP Code:
<if !(THIS_SCRIPT == 'index.php') then><navigation></if>


-.- Of course. I must've accidentally removed it when I was failing to add an additional clause in there.
Ah, I see how you did it.  Thanks for posting the template.
How would I go about hiding something if the user is logged in?

Code:
<if !$mybb->user['uid'] then>
stuff
</if>

How can I put a recount of threads in a "x" forum in users profile?

for example:

"Profile of some user"

Videos: 15 (The videos forum is fid=4)
Photos: 13 (The pictures forum is fid=3)
Posts: 169 (Fid= 5,6,7,7,8,8,9,3)
It's not really something for PHP in Templates to do unfortunately.
It will be great if that were possible :/ Is there another method?
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Reference URL's