MyBB Community Forums
Navigation - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Development (https://community.mybb.com/forum-68.html)
+---- Thread: Navigation (/thread-24650.html)

Pages: 1 2


Navigation - BrandMan211 - 2007-10-12

Hi all,

I've been working on a forum embed, and once we got the site template into the MyBB system, I thought, why would I risk imperfections and update both the site and the forum if I could make it so the site uses the forum skin? Well, after a while, I came up with a code that would embed site pages into the MyBB template.

<?php

// Get access to MyBB stuff
define("IN_MYBB", 1);

chdir(board); // path to MyBB
require './global.php';

echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>{$mybb->settings['bbname']}</title>
{$headerinclude}
</head>
<body>
{$header}
<center>";
?>

<!-- ************************************************************************************************************* CONTENT BEGIN **** -->
        <?php
		include($pagename);
	?>	
<!-- ************************************************************************************************************* CONTENT END ****** -->

<?

echo "</center>
{$footer}
</body>
</html>";

?>
The code worked PERFECTLY, except, there was one problem. You see, the navigation for the forum is outputted with the tag <navigation>, and when you are not in MyBB, it can not interpret it and it marks it as invalid. Also, the <br/> which comes before it interferes with the site content. What I was wondering is, would anyone happen to know what could omit that line from pages that are not located in MyBB? Other than that, everything works perfectly, in terms of the forum embed.

Thanks,
BrandMan211


RE: Navigation - Ryan Ashbrook - 2007-10-12

I suggest you use templates instead of using echo() for your HTML, that way anything in regards to templates will work perfectly, including <navigation>.

Then call the template using this code:

eval("\$templatename = \"".$templates->get("templatename")."\";");
			output_page($templatename);



RE: Navigation - BrandMan211 - 2007-10-12

Well, that's the thing. I really don't know where the Doctype / Tags are located normally in MyBB. I didn't see them in any templates, so I assumed they were put in some of the PHP files or something. Am I wrong?


RE: Navigation - Ryan Ashbrook - 2007-10-12

{$htmldoctype} I believe is the code to output the Doctype.


RE: Navigation - BrandMan211 - 2007-10-12

Maybe I misunderstood you, but

<?php

// Get access to MyBB stuff
define("IN_MYBB", 1);

chdir(board); // path to MyBB
require './global.php';

eval("\$templatename = \"$templatename)".$templates->get("htmldoctype")."\";");
            output_page($templatename);
eval("\$templatename = \"$templatename)".$templates->get("headerinclude")."\";");
            output_page($templatename);
eval("\$templatename = \"$templatename)".$templates->get("header")."\";");
            output_page($templatename);
?>

<!-- ************************************************************************************************************* CONTENT BEGIN **** -->
        <?php
		include($pagename);
	?>	
<!-- ************************************************************************************************************* CONTENT END ****** -->

<?

eval("\$templatename = \"$templatename)".$templates->get("footer")."\";");
            output_page($templatename);

?>
Does not work.


RE: Navigation - LeX- - 2007-10-12

Its
eval("\$outputpage = \"".$templates->get("header")."\";");
echo $outputpage;



RE: Navigation - BrandMan211 - 2007-10-12

<?php

// Get access to MyBB stuff
define("IN_MYBB", 1);

chdir(board); // path to MyBB
require './global.php';
eval("\$outputpage = \"".$templates->get("htmldoctype")."\";");
output_page($outputpage); 
eval("\$outputpage = \"".$templates->get("headerinclude")."\";");
output_page($outputpage); 
eval("\$outputpage = \"".$templates->get("header")."\";");
output_page($outputpage); 
?>

<!-- ************************************************************************************************************* CONTENT BEGIN **** -->
        <?php
		include($pagename);
	?>	
<!-- ************************************************************************************************************* CONTENT END ****** -->

<?

eval("\$outputpage = \"".$templates->get("footer")."\";");
output_page($outputpage); 

?>
Outputs:
Quote:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><!-- start: htmldoctype -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- end: htmldoctype -->
Any ideas?


RE: Navigation - LeX- - 2007-10-12

<?php

// Get access to MyBB stuff
define("IN_MYBB", 1);

chdir(board); // path to MyBB
require './global.php';
eval("\$outputpage = \"".$templates->get("htmldoctype")."\";");
echo $outputpage; 
eval("\$outputpage = \"".$templates->get("headerinclude")."\";");
echo $outputpage; 
eval("\$outputpage = \"".$templates->get("header")."\";");
echo $outputpage; 
?>

<!-- ******************************************************************************** ***************************** CONTENT BEGIN **** -->
        <?php
        include($pagename);
    ?>    
<!-- ******************************************************************************** ***************************** CONTENT END ****** -->

<?
eval("\$outputpage = \"".$templates->get("footer")."\";");
echo $outputpage;  

?>



RE: Navigation - BrandMan211 - 2007-10-12

Ok, that code worked, and it's awesome, but I still have the problem with the navigation, and I truly do not understand how to fix it.

Also, there do seem to be some missing parts with only these templates: the title, the missing end codes, and I'm not sure where the <head> is, even though it says it's there. Anyone know any other templates I should add to fix this?


RE: Navigation - Ryan Ashbrook - 2007-10-15

This is an example PHP file for integration in MyBB (this is just a quick draw up, I don't recommend using it).

<?php

// Make sure we're in mybb.
define('IN_MYBB', 1);

require('./global.php');

eval("\$my_page = \"".$templates->get("my_page")."\";");
output_page($my_page);

?>

Again this is very basic as it is just a quick draw up of what you would need.


header, headerinclude, and htmldoctype are automatically called via global.php


You need to build a template using this:

{$htmldoctype}
<html>
<head>
<title>{$mybb->settings['bbname']} - Page Title</title>
{$headerinclude}
</head>
<body>
{$header}

CONTENT HERE
		
{$footer}
</body>
</html>

So pretty much move the stuff from the included file to where it says CONTENT HERE and all should be done.


Again, this is just a quick build-up of how to do this, s I would recommend tinkering around with it.

Also, I have blocked you on AIM, please read my signature.