[SMF 1.1.x] Integrating the forum into your site using SMF\'s layer system

Started by Daniel15, January 27, 2007, 02:49:11 AM

Previous topic - Next topic

reynierpm

Hi:
I try to integrate the SMF into my site and this post is amazing but I have some problems. Im my application I have two files: header.php and footer.php. The header file contains all stuff goes in header. Where I need to place this two files? I can use from outside directory? I mean:

L assets
L templates
  L mytemplate
   L css
   L images
   L jscript
   header.php
   footer.php
L foro
L Themes
  L mynewtheme
  index.template.php

Understand? Also I run the query and I get this error:
QuoteUnable to load the 'header_above' template.
Can any help me?
Cheers

IchBin™

From the original post:
QuoteThe index.template.php file assumes that header.php and footer.php are in your forum's directory.

Don't know about your error. It could be because you don't have the files in the right place.
IchBin™        TinyPortal

reynierpm

Quote from: lebisol on February 19, 2007, 07:24:35 PM
Quotei don't get where i have to put the header and footer
belive it or not I had better luck following the article from Unknown that loopbacks to this one :)
http://www.simplemachines.org/community/index.php?topic=19638.0

Hi:
I try both and nothing is showed to me. Besides I get this error:
Quoteinclude(footer.php) [function.include]: failed to open stream: No such file or directory

See the image attached

spottedhog

If you have the file "header.php" in the same location as Settings.php or SSI.php, then you can have this in the index.template.php:

// Show the menu here, according to the menu sub template.
template_menu();

include('header.php');

// The main content should go here.


That would put your header.php file just under where the navigational buttons are.

If you wish to have the footer.php file to display just above the regular theme's footer location, use this:

function template_main_below()
{
global $context, $settings, $options, $scripturl, $txt;

include('footer.php');


Again, both of these assume header.php or footer.php are in the root directory of your forum files, same location as Settings.php or SSI.php

reynierpm


spottedhog

Your "include" should look like this:

include('Themes/SIMPRO/footer.php');

Farmacija

Quote from: Daniel15 on January 27, 2007, 02:49:11 AM


The layer system - What is it?
SMF's templating system uses a thing called "layers". Essentially, a layer is simply two sub-templates, one that goes above the content, and another that goes below the content. For example, the default layer is called "main", which means that "main_above" is above the content, and "main_below" is below the content:

Since you're integrating the forum into your site, we'll add a new layer called "site". This layer will be before the "main" layer, so the order will be site_above --> main_above --> Content --> main_below --> site_below

Very first steps - Website template
The first thing you need is get the contents for the new layer. I assume that you have a HTML template for your current site, so we'll use that. For the purposes of this tutorial, I'll be using this template:

<!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>Test</title>
</head>

<body>
<h1 align="center">My really cool website</h1>
<div align="center"><a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a></div>
<hr />

This would be the actual content!<br />
bla bla bla

<hr />
&copy;2007 Your site
</body>
</html>

You will need to split this into two files, one for the header and one for the footer. For the header, copy all text after the <body> tag until the point where the page content begins, and save this into a file called header.php. For the purpose of this tutorial, this code would be used:

<h1 align="center">My really cool website</h1>
<div align="center"><a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a></div>
<hr />

You also need to do a similar thing for the footer. Copy all the text from the end of the content until the </body> tag, and save it into a file called footer.php. Again, for the purpose of this tutorial, this code will be used:

<hr />
&copy;2007 Your site



Hm, i don't understand, how i can determine which content from <hr> to </body> should i copy in new file when there isn't certain <hr> tag in index.template.php file for smf default theme?  :o
www.farmaceuti.com
www.farmaceuti.com/tekstovi

spottedhog

Your code with the footer.php file could look something like this (from the index.template.php file):

function template_main_below()
{
global $context, $settings, $options, $scripturl, $txt;

include('footer.php');

Farmacija

ok, but how we can alone split index.template.php? and is there some smf color compatibile template for index page of site[ not forum] ?
www.farmaceuti.com
www.farmaceuti.com/tekstovi


Farmacija

No, i read it alrady and you aren't helping me.
i want the reverse process.
to use smf header and footer to another custom pages and i just need what and how i sholud delete the boards list and make it clear to put another content on their place?
www.farmaceuti.com
www.farmaceuti.com/tekstovi

spottedhog

OK, I will take the information I got from the 1st page of the above link and give you an example...

Try this:

<?php
require('./smf/SSI.php');
template_main_above();

//Site content goes here
include "../includes/content.php";

template_main_below();
?>


Or another way could be this:

REPLACE INTO yourprefix_themes
   (ID_THEME, variable, value)
VALUES (that number, 'theme_layers', 'site,main');

(where "yourprefix_" is your prefix, often 'smf_' and "that number" is the theme id you wish to use)

<?php

error_reporting
(E_ALL);

$ssi_theme = 1; //or whatever ID_THEME you are using
$ssi_layers = array('site');

// If you want SSI.php to start gzipping for you ;).
$ssi_gzip = true;

require(
'path/to/your/SSI.php');

echo
'Your page stuff go here';

ssi_shutdown();

?>


...and yes, I was helping you.  What I listed here I took from the link above.

Farmacija

ok , tell me how i can incorporate smf hedaer and foote for this custom html page
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Razmena banera</title>
</head>
<body>
<body><table width="100%"  border="0"><tr><td width="45%"></td><td bgcolor="#E9F0F6" align="right">
    <font size="2" color="#FFFFFF" face="Verdana">
    <a href="http://www.farmaceuti.com/forum">Forum&nbsp; </a> |
    <a href="http://www.farmaceuti.com/chat/chat">Chat&nbsp; </a> |
    <a href="http://www.farmaceuti.com/tekstovi">Tekstovi&nbsp</a> |
    <a href="http://www.farmaceuti.com/marketing.html">Marketing</a> |
    <a href="http://www.farmaceuti.com/forum/links">Linkovi</a> |
    &nbsp;
    </font></td><td width="10%"></td></tr></table><p></p>
<table width="100%"  border="0" cellpadding="1" cellspacing="0" bgcolor="#666666">
  <tr>
    <td><table border="0" width="100%" cellspacing="5" cellpadding="5" bgcolor="#FFFFFF" bordercolor="#666666">
  <tr>
    <td>
      <p align="center"><font size="6" face="Georgia">Forum farmaceuta ::
      </font><font face="Georgia" size="6" color="#336699">Saradnja</font><font size="6" face="Georgia"><br>
      </font><font size="4" face="Georgia">Razmena banera/linkova
      </font><font size="4" face="Georgia">&nbsp;</td>
  </tr>
  <tr>
    <td bgcolor="#F4F4F4" valign="top" align="center">
     <table width="80%"  border="0" align="center" cellpadding="14" cellspacing="35" bgcolor="#F4F4F4">
  <tr><td>
    <font face="Georgia,Helvetica,Times New Roman, Arial" color="#003148" size="4">Razmenu banera Farmacija forum ce obavljati sa sajtovima koji ispunjavaju sledece uslove:
<p><li> Imaju Page Rank minimum 3. <a href="http://www.prchecker.info">Proveriti PR ovde</a></li></p>
<p><li> Alexa rating bar u prvih 500000 sajtova [ uz svu nepouzdanost Alexa servisa za komparaciju sajtova, to nam je jedini nacin da dodjemo do neke priblizne informacije o posecenosti sajta sa kojim treba da razmenimo baner/link]</li>
    <p><li> Ako ste prijavljeni na topsajt.com top listu potrebno je da imate bar 300 posetilaca dnevno</li></p>
<p> Vas baner/link ce biti postavljen na pocetnu stranu foruma ili u odgovarajuci forum u zavisnosti od dogovora, reciprocitet je pozeljan.</p>
<p>Banere cemo razmenjivati samo sa sajtovima/forumima koji ispunjavaju odredjene kriterijume</p>
<p> Banere za razmenu saljite na mail: marketingforuma[et]gmail.com sa naznakom "razmena banera"<p>&nbsp;</p>


</font></td>
  </tr>
  <tr><td><script language="JavaScript">
<!--
  // Hit counter code for Webstat.net
  var data = '&r=' + escape(document.referrer)
+ '&n=' + escape(navigator.userAgent)
+ '&p=' + escape(navigator.userAgent)
+ '&g=' + escape(document.location.href);
  if (navigator.userAgent.substring(0,1)>'3')
    data = data + '&sd=' + screen.colorDepth
+ '&sw=' + escape(screen.width+'x'+screen.height);
  document.write('<img alt="Free Counter and Web Stats" width="0" height="0" border="0" hspace="0" '+'vspace="0" src="http://www.webstat.net/basic/counter.php?i=19290' + data + '">');
// -->
</script></td></tr>
</table></table></table>
    <table width="100%" bgcolor="white"><tr><td>

<script type="text/javascript"
src="http://widgets.alexa.com/traffic/javascript/graph.js"></script>

<script type="text/javascript">/*
<![CDATA[*/

   // USER-EDITABLE VARIABLES
   // enter up to 3 domains, separated by a space
   var sites      = ['www.farmaceuti.com  '];
   var opts = {
      width:      80,  // width in pixels (max 400)
      height:     30,  // height in pixels (max 300)
      type:       'r',  // "r" Reach, "n" Rank, "p" Page Views
      range:      '6m', // "7d", "1m", "3m", "6m", "1y", "3y", "5y", "max"
      bgcolor:    'e6f3fc' // hex value without "#" char (usually "e6f3fc")
   };
   // END USER-EDITABLE VARIABLES
   AGraphManager.add( new AGraph(sites, opts) );

//]]></script>

</td><td align="center"> <img src="http://www.farmaceuti.com/BANERI/Mainkonacno.gif" alt="Postpaid internet" height="60" width="468" ></div>
    </td></tr>
    </font><script language="JavaScript">
<!--
  // Hit counter code for Webstat.net
  var data = '&r=' + escape(document.referrer)
+ '&n=' + escape(navigator.userAgent)
+ '&p=' + escape(navigator.userAgent)
+ '&g=' + escape(document.location.href);
  if (navigator.userAgent.substring(0,1)>'3')
    data = data + '&sd=' + screen.colorDepth
+ '&sw=' + escape(screen.width+'x'+screen.height);
  document.write('<img alt="Free Counter and Web Stats" width="0" height="0" border="0" hspace="0" '+'vspace="0" src="http://www.webstat.net/basic/counter.php?i=19290' + data + '">');
// -->
</script>
    </td>
  </tr>

</table>
</form>
    </td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">
      <p align="center"><b><font size="2" face="Georgia"><span style="color: #006595">Copyright FF-Sva prava zadrzana! </span></a></font></b></td>
  </tr></table></td></tr></table></td>
</tr></table>
</body>
</html>
www.farmaceuti.com
www.farmaceuti.com/tekstovi

spottedhog

Something similar to this may work....

That custom html page, name it content.html  Remove <body> and everything before it.  Remove </body></html> from the bottom of the file.

Then for your custom page for the SMF headers and footers, use this:

<?php
require('./path/to/SSI.php');
template_main_above();

//Site content goes here
include "./content.html";

template_main_below();
?>


By the way....  That custom html page is no where close to being XHTML compliant....

Farmacija

nope
QuoteWarning: main(./path/to/SSI.php): failed to open stream: No such file or directory in c:\program files\easyphp1-7\www\forum\smf_1-1-1_install\razmenabanera1.php on line 2

Fatal error: main(): Failed opening required './path/to/SSI.php' (include_path='.;C:\Program Files\EasyPHP1-7\php\pear\') in c:\program files\easyphp1-7\www\forum\smf_1-1-1_install\razmenabanera1.php on line 2
www.farmaceuti.com
www.farmaceuti.com/tekstovi

spottedhog

require('./path/to/SSI.php');  <--- replace "/path/to" with the actual path to your SSI.php file.

Sorry about not explaining that part.

Farmacija

www.farmaceuti.com
www.farmaceuti.com/tekstovi

spottedhog

Here is some code to use to create your own start page or another page.  I tried to leave comments within the code to make things clear.

<?php

$ssi_gzip
= true;  //true--means gzip is turned on.
$ssi_ban = true;  //true--means a banned forum user will be banned also in the SSI page.
//$ssi_theme = 2;  //uses the theme [images, buttons, colors] with ID=2, which usually is classic theme.  Specifiy theme ID to use.
//Leave as is to use the default theme or the member's theme.
ob_start();  //is needed not to get errors.

require($_SERVER['DOCUMENT_ROOT'].'/SSI.php');

$context['page_title'] = 'test page'; //needs to go above template_main_above(); to display Page Title

template_main_above();

//include('header.php'); //Contents of a custom header.php file.  Displayed immediately under the template_menu();  Uncomment to display.


//Page content goes here


//include('footer.php'): //Contents of a custom footer.php file.  Displayed above SMF copyright line.  You could put your own footer info here.  Uncomment to display.
template_main_below();

?>

Farmacija

<?php

$ssi_gzip
= true;  //true--means gzip is turned on.
$ssi_ban = true;  //true--means a banned forum user will be banned also in the SSI page.
//$ssi_theme = 2;  //uses the theme [images, buttons, colors] with ID=2, which usually is classic theme.  Specifiy theme ID to use.
//Leave as is to use the default theme or the member's theme.
ob_start();  //is needed not to get errors.

require('C:/Program Files/EasyPHP1-7/www/forum/smf_1-1-1_install/SSI.php'); //replace path/to  with actual path.

$context['page_title'] = 'test page'; //needs to go above template_main_above(); to display Page Title

template_main_above();

//include('header.php'); //Contents of a custom header.php file.  Displayed immediately under the template_menu();  Uncomment to display.


//Page content goes here
hkhkgjhjlhlkhl test test test

//include('footer.php'): //Contents of a custom footer.php file.  Displayed above SMF copyright line.  You could put your own footer info here.  Uncomment to display.
template_main_below();
?>


QuoteParse error: parse error, unexpected T_STRING in c:\program files\easyphp1-7\www\forum\untitled1.php on line 22
www.farmaceuti.com
www.farmaceuti.com/tekstovi

spottedhog

try this:

echo 'hkhkgjhjlhlkhl test test test ';

...this is basic php.... maybe you should look over some PHP Coding tutorials.  I think there may be some here somewhere.

Advertisement: