[Rejected] Unnecessary code?
I'm trying to figure out the differences between index.php and forumdisplay.php so I can isolate the thread list code.

In index.php there is reference to logout link at beginning:

$logoutlink = '';
if($mybb->user['uid'] != 0)
eval('$logoutlink = "'.$templates->get('index_logoutlink').'";');

And no such reference in forumdisplay.php. Yet the latter does show the logout link just fine. So how does that work?

I removed that code from index.php and see no difference. Does it have any use?
The template ist used for the logout link in the forums statistics. Removing the code removes that link.
[Image: banner.png]
Alright thanks. That's a problem for a MyBB newcomer like me who can code but doesn't know all the ins and out of how the board works. I do grep or something similar to learn my way around the code but the templates are in the database, so they don't show up when I search for   a variable and the like.

I guess I'll have to extract all the templates into separate files so Ican do proper searches in the code base.
The templates are in a separate file together with .css - install/resources/mybb_theme.xml. You can grep them with no problem if you include the .xml extension in your results.

They wouldn't be inserted to the DB in the 1st place if they didn't exist in any file (or an online resource, which would cause problems like failed installation in case of any downtime).
Yes I figured that out Smile

My grep wasn't configured to include xml. And in the meantime I made a script to extract the templates to html files.

Turns out that is still more useful, since grep tells me exactly what template matches the search term, such as "index_boardstats.html" instead of returning "mybb_theme.xml" all the time.

Plus for longer templates I can see syntax highlighted code in my editor much quicker than finding it in the Dashboard.

Here is the dirty as heck code for anyone who cares:

 * Extract all the MyBB templates into a folder.

define("IN_MYBB", 1);
define("NO_ONLINE", 1);
define('THIS_SCRIPT', 'extract_templates.php');

require_once "./inc/init.php";

// chose a subdirectory where we edit stylesheets
define('TEMPLATES_PATH', MYBB_ROOT.'/templates/');

if ($argv[1] === '-x')
  $query = $db->query("SELECT tid, title, template FROM mybb_templates WHERE sid = -2 ORDER BY title ASC");

  echo sprintf("%d templates\n", $db->num_rows($query));

  $n = 0;

  while ($row = $db->fetch_array($query))

    $tid      = $row['tid'];
    $title    = $row['title'];
    $template = $row['template'];

    $file = TEMPLATES_PATH.$title.'.html';
    if (false !== ($length = file_put_contents($file, $template)))
      echo sprintf("%04d. Extracted '%s' (%d bytes)\n", $n, $title, $length);

  echo "Use -x to extract templates.\n";

Forum Jump:

Users browsing this thread: 1 Guest(s)