MyBB Community Forums

Full Version: Template changes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When template variables are removed from the template files, do their associated functions still get called from the PHP files?

I'll give you an example of this. If I were to remove {$lastpost_link} from forumbit_depth2_forum_lastpost, does the 'get_thread_link' function still get called from the './inc/functions_forumlist.php' file?

$lastpost_link = get_thread_link($lastpost_data['lastposttid'], 0, "lastpost");
Yes, of course, the function will still be there. Deleting variables in your templates won't delete code from the files.
Thanks for the reply.

My example may not have been the best when trying to explain what I was asking. I know the template changes don't result in the core files being changed.

Perhaps a better example:

In the search template, the variable {$srchlist} returns the forum list. We can locate this variable in './search.php':

$srchlist = make_searchable_forums("", $fid);

and find it calls the function 'make_searchable_forums' from './inc/functions_search.php':

function make_searchable_forums($pid="0", $selitem='', $addselect="1", $depth='')
{
	global $db, $pforumcache, $permissioncache, $mybb, $selecteddone, $forumlist, $forumlistbits, $theme, $templates, $lang, $forumpass;
	$pid = intval($pid);

	if(!is_array($pforumcache))
	{
		// Get Forums
		$query = $db->simple_select("forums", "pid,disporder,fid,password,name", "linkto='' AND active!=0", array('order_by' => "pid, disporder"));
		while($forum = $db->fetch_array($query))
		{
			$pforumcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
		}
	}
	if(!is_array($permissioncache))
	{
		$permissioncache = forum_permissions();
	}
	if(is_array($pforumcache[$pid]))
	{
		foreach($pforumcache[$pid] as $key => $main)
		{
			foreach($main as $key => $forum)
			{
				$perms = $permissioncache[$forum['fid']];
				if(($perms['canview'] == 1 || $mybb->settings['hideprivateforums'] == 0) && $perms['cansearch'] != 0)
				{
					if($selitem == $forum['fid'])
					{
						$optionselected = "selected";
						$selecteddone = "1";
					}
					else
					{
						$optionselected = '';
						$selecteddone = "0";
					}
					if($forum['password'] != '')
					{
						if($mybb->cookies['forumpass'][$forum['fid']] == md5($mybb->user['uid'].$forum['password']))
						{
							$pwverified = 1;
						}
						else
						{
							$pwverified = 0;
						}
					}
					if(empty($forum['password']) || $pwverified == 1)
					{
						$forumlistbits .= "<option value=\"{$forum['fid']}\">$depth {$forum['name']}</option>\n";
					}
					if($pforumcache[$forum['fid']])
					{
						$newdepth = $depth."&nbsp;&nbsp;&nbsp;&nbsp;";
						$forumlistbits .= make_searchable_forums($forum['fid'], $selitem, 0, $newdepth);
					}
				}
			}
		}
	}
	if($addselect)
	{
		$forumlist = "<select name=\"forums[]\" size=\"20\" multiple=\"multiple\">\n<option value=\"all\" selected=\"selected\">$lang->search_all_forums</option>\n<option value=\"all\">----------------------</option>\n$forumlistbits\n</select>";
	}
	return $forumlist;
}

You will see the above function contains a query. My question: if I simply removed the original variable from the template files ('$srchlist'), will this function get called (unless, of course, it is used elsewhere).

The reason I ask is because some functions make database calls. One further example would be the 'Forum Jump' feature -- I can't locate it at the moment, but, if I were to remove the string from the template files, does the query for the forum list still get called?

From simply posting this thread, and posting those examples, I'm starting to think the answer is 'no'.



I hope I don't sound condescending by giving yet another example. Thanks again.
No, it does not get called nor is the query ran.