MyBB Community Forums

Full Version: Custom Page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Ive placed a custom mybb page inside a new folder in my forum root, my custom page contains all the default variables like {headerinclude} etc. But the page is not displaying some images. Its looking for images in my new folder ?

Heres an example, you see the new page is looking for an image in:
Quote:/newfolder/images/toplinks/search.gif

Here my custom page:
Quote:<?php
define("IN_MYBB", 1);
require_once "../global.php";

$template .= '
<html>
<head>
{$headerinclude}
</head>
<body>
{$header}

Content goes here

{$footer}
</html>';

$template=str_replace("\'", "'", addslashes($template));
eval("\$page=\"".$template."\";");
output_page($page);
?>

Why is it looking for images in my new folder ?
Don't evaluate or make template code inside it. Instead just use it by creating global templates and then evaluating it; http://community.mybb.com/thread-116225.html
This is not a plugin, nor do I want to use global templates. This method has worked in the past.
The code is failing to find the global.php. You've to play and adjust require_once "../global.php"; so it finds the correct path of ./global.php
(2012-06-30, 03:19 PM)Frank.Barry Wrote: [ -> ]Ive placed a custom mybb page inside a new folder in my forum root, my custom page contains all the default variables like {headerinclude} etc. But the page is not displaying some images. Its looking for images in my new folder ?

Heres an example, you see the new page is looking for an image in:
Quote:/newfolder/images/toplinks/search.gif

Here my custom page:
Quote:<?php
define("IN_MYBB", 1);
require_once "../global.php";

$template .= '
<html>
<head>
{$headerinclude}
</head>
<body>
{$header}

Content goes here

{$footer}
</html>';

$template=str_replace("\'", "'", addslashes($template));
eval("\$page=\"".$template."\";");
output_page($page);
?>

Why is it looking for images in my new folder ?

Some images use relative links. One way to solve the issue is to add the following to your headerinclude template:

<base href="{$mybb->settings['bburl']}/" />
(2012-06-30, 08:54 PM)Yaldaram Wrote: [ -> ]The code is failing to find the global.php. You've to play and adjust require_once "../global.php"; so it finds the correct path of ./global.php


Yes but "../global.php" is the correct path fo the folder I'm using. If I place the file in the forum root and use "global.php", it works perfectly.
Try this (not sure if it works since I'm not aware about the path where the file has been placed);
require_once "../../global.php";
(2012-06-30, 10:08 PM)Yaldaram Wrote: [ -> ]Try this (not sure if it works since I'm not aware about the path where the file has been placed);
require_once "../../global.php";

No thats 2 folders back, Im only one folder up from global.php.

My folder:
Quote:/root/myfolder/
Did you try my suggestion at all?
The reason is that the img path is not converted. Try editing your global.php to add your forum url before the imgdir variable, or euantor suggestion.
Pages: 1 2