Customizing SMF > Portals, Bridges, and Integrations
SMF 2.0 site integration page title not passing
(1/1)
kaiya:
I'm setting up a site integration and am using SSI as follows. Everything is working ok with my current set up, except that the page has no title at all (nothing between the <title> tags in the html) and I can't work out how to add it.
--- Code: ---<?php
$ssi_gzip = false;
$ssi_ban = true;
$ssi_theme = '3';
$ssi_layers = array('html', 'body');
ob_start();
require("SSI.php");
--- End code ---
I've tried sticking the following in at various positions but it makes no difference - I still have nothing between the <title> tags.
--- Code: ---$context['page_title_html_safe'] = 'page title here';
--- End code ---
I'd prefer each of my outside pages to have their own title but frankly I'd settle for any title at the moment!
In addition, all of the resources for site integration I've read here seem to be for 1.1 - I've had a successful 1.1 integration running for years but there seem to be subtle differences between the two and no information for 2.0 yet, and it's enough to throw some curve balls. Am I just missing the really obvious SMF 2.0 site integration post?
The Burglar!:
For smf 2.0 site integrate look at this post in de dev blogs board Simple Machines Website-Forum Integration
This tutorial wil help you a bit but you need to be a more coder for it couse it contains some errors wich needed to be fixed but its more towards SMF 2.0 site intergrate then you have read ;)
check yoursite.url/ssi_examples.php for the correct path of your SSI.php
do not use
--- Code: ---require("SSI.php");
--- End code ---
replace that with
--- Code: ---<?php
require_once('/path/to/your/SSI.php');
ob_start();
$ssi_gzip = false;
$ssi_ban = true;
$ssi_theme = '3';
$ssi_layers = array('html', 'body');
ob_exit();
?>
--- End code ---
spottedhog:
Try this:
--- Code: ---global $context;
$context['page_title_html_safe'] = 'page title here';
--- End code ---
Depending upon how and where SSI.php is called, you may have to "global" $context. For example, if you are using a function, you will need to "global", while if the page is not within a function, then $context should work OK.
Try this to see what is available in the $context variable:
--- Code: --- global $context;
echo '<pre>';
print_r($context);
echo '</pre>';
--- End code ---
kaiya:
Thank you for the replies! Unfortunately (despite evidently taking a break from the project) I've had no luck fixing this issue.
I tried:
--- Code: ---<?php
require_once('./community/SSI.php');
ob_start();
$ssi_gzip = false;
$ssi_ban = true;
$ssi_theme = '3';
$ssi_layers = array('html', 'body');
ob_exit();
global $context;
$context['page_title_html_safe'] = 'page title here';
//page content
ssi_shutdown();
?>
--- End code ---
and got - Fatal error: Call to undefined function ob_exit() in /home/hfshccom/public_html/index.php on line 11
I removed ob_exit; and got a unformatted page (no theme called).
I tried:
--- Code: ---<?php
$ssi_gzip = false;
$ssi_ban = true;
$ssi_theme = '1';
$ssi_layers = array('html', 'body');
ob_start();
global $context;
$context['page_title_html_safe'] = 'page title here';
require("./community/SSI.php");
//page content
ssi_shutdown();
?>
--- End code ---
Which doesn't pass 'page title here' to $context or give the page a title
and I tried:
--- Code: ---<?php
$ssi_gzip = false;
$ssi_ban = true;
$ssi_theme = '1';
$ssi_layers = array('html', 'body');
ob_start();
require("./community/SSI.php");
global $context;
$context['page_title_html_safe'] = 'page title here';
//page content
ssi_shutdown();
?>
--- End code ---
Which does pass 'page title here' to $context but the page title in the html is still null.
I've read through http://www.simplemachines.org/community/index.php?topic=163770.0 but none of the solutions there seem to work - most seem to be for 1.1 with references to $ssi_layers = array('main'); and template_main_above(); and template_main_below(); which are undefined functions when I try to call them in 2.0.
I have however reached a solution (hence posting - may be useful for others with the same issue).
--- Code: ---<?php
$ssi_gzip = false;
$ssi_ban = true;
$ssi_theme = '1';
require("./pathto/SSI.php");
$context['page_title_html_safe'] = 'page title here';
template_html_above();
template_body_above();
echo'Content Here';
template_body_below();
template_html_below();
?>
--- End code ---
Hopefully it's a safe solution.
spottedhog:
try this instead:
--- Code: ---<?php
$ssi_gzip = false;
$ssi_ban = true;
//$ssi_theme = '1';
require("./pathto/SSI.php");
$context['page_title_html_safe'] = 'page title here';
template_header();
echo 'Content Here';
template_footer();
?>
--- End code ---
Here is a page coded like above, in action: http://montco-in.tpsites.us/errors404.php
It is one of 5 custom error pages I use. Look closely and you will see the SMF template in place with custom content sandwiched between the header and footer.
Navigation
[0] Message Index
Go to full version