News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Index/Default Dynamic Forum Content

Started by Cheese Head, February 10, 2008, 07:45:03 AM

Previous topic - Next topic

Cheese Head

mornin y'all, small help question please. I have SMF installed and running, now I want to put some dynamic content on my index/default page.

What's that called and where on SMF website should I look for how-to?

Thx, John.

Dragooon


Cheese Head

Yes please, my Forum is actually just part of my website not the only thing, so yes how to insert dynamic recent Forum posts into my Homepage/Default/Index file.


Cheese Head

Thanks karlbenson, appreciate, wish me luck, John.

Cheese Head

#5
Edit: Oops, just realized this is in SMF1.0 Support board, I'm now using 2.0, moderator please move post if like . . . thanks

So I've just spent almost a day trying to figure out SSI so that I can make my homepage dynamic with recent posts and I'm still stuck. So far I've:

  • Read through the 3 Beginner/Advanced/Expert tutorials and many of the subsequent posts.
  • Read through the simple Using SSI.php online manual.
  • And done lots of playing around with different snippets of code in .php.
When I come to implement into my default.html homepage I realize that:

  • My playing with snippets in a .php file that I FTP up to my site is probably useless as when I cut and paste that into my default.html it's in wrong language, correct?
  • I don't understand the difference between .html and .shtml?
  • I need to use .shtml file name extension, can I do that for my index page, won't that mean that google users who have book marked my homepage etc won't find it?
  • I look at the ssi_examples.shtml file and don't understand it as it appears to be the results not the requesting code I want?

Appreciate any advice as I feel I've lost a day and am worse off when I started. All I want to do is show the 10 most recent posts on my index.html homepage.

Thanks, John.

Sarge

Hello John, simply put the PHP code inside <?php and ?> and the webserver will parse it with PHP.

    Please do not PM me with support requests unless I invite you to.

http://www.zeriyt.com/   ~   http://www.galeriashqiptare.net/


Quote
<H> I had zero posts when I started posting

Cheese Head

#7
Hi Sarge

OK, I've put the code inside <?php and ?>  into my default.htm homepage:
Quote<p>Please have a look, enjoy, participate, and come back soon . . . John, Webmaster.</p>

<?php
require("/home/jlsr12/public_html/forum/SSI.php");

$array = ssi_recentTopics(10, null, 'array');
   foreach ($array as $recent)
   {
      echo '
      <a href="', $recent['href'], '" title="Board: ', $recent['board']['name'], ' - Poster: ', $recent['poster']['name'], '">
      ', $recent['subject'], '
      ', $recent['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $recent['topic'] . '.from' . $recent'newtime'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '
      ', $news['body'], '
      </a><br/>';
   }
?>

<!-- #EndEditable --></div>
</td>
I then FTP'd the file to my host but my online homepage still doesn't show any change. I don't think it is as easy as putting php code into an html type file.

Any advice appreciated, all I'm trying to do is make my homepage dynamic with 10 most recent posts to entice viewers to click into the forum.

Dragooon

It should be a .php File not .htm or .html

Cheese Head

Fully agree it should be in a php file and that's where I've been experimenting with SSI as per the tutorials. But I want to include it into my default.htm homepage, how do I do that?

Dragooon

You can do it this way
<?php
echo 'YOUR HTML HERE';
?>

Make sure you escape quotes( ' ) with backslashes ( \ ).

Cheese Head

Dragooon thanks for your help, sadly I don't fully understand.

I have a default.html that I want to put some SSI in. But I think you are saying the opposite, change my default.htm homepage to php language file and cut and paste the htm code into it?

I really don't want to go down that road as I have a Dynamic Web Template and CSS for my webpages so I'd have to junk all that and basically rebuild my website.

There must be a way to put SSI into an default.htm file or 95% of people build their websites in php?

Thanks again for your support . . .

Dragooon

You cannot use SSI in HTML(not directly atleast). You will be needing to either use SHTML or PHP(recommended).

Cheese Head

Dragooon, so you are saying that to have SSI on my homepage I need to unlearn HTML, CSS, and DWT and best to learn PHP and rebuild my website in PHP? Ouch that means probably up to 1 month work plus probably buying new guide books and software as I bought MS Expression Web 1 (instead of Dreamweaver) which will code php files but is really built for html & CSS . . . MS Expression Web 2 is now out features page here.

I just googled SHTML and it looks similar as it's a server side include version of HTML, wouldn't that be easier for me and if so what do I have to do?

Dragooon

PHP do uses a LOT of HTML(See SMF's files for example, HTML is the way to output the data, PHP collects the data).
And are you trying to enclose your whole site in SSI or just 1 page?

You can also ask at the Help Wanted board if you want someone to do it for you.

Cheese Head

Thanks Dragooon, just one page, all I want to do is have my homepage show the latest posts as a way of enticing viewers to click through and look at posts in the forum.

But If I convert my default.htm into I assume default.php so that I can include SSI then I will not be able to use CSS or DWT for that page making it very awkward to have one page different from the rest. I guess I could just rewrite that page and menus but there must be an easier way via shtml . . . thanks anyway, I'm hoping someoone will reply with a html way to incude SSI . . .

Dragooon

You cannot use HTML and SSI together

BTW, You can use CSS and DWT just fine(you basically can use everything you use in HTML(see www.php.net)).

Something like
<?php
global $context;
require_once(
'SSI.php');
echo 
'
<html>
<head>
<link rel="stylesheet" src="blabla.com/style.css" type="text/css" />
</head>
<body>
Bla bla bla
</body>
</html>'
;
?>


Thats how SMF does it, SMF doesn't uses any static HTML files, all of the HTML/CSS/JScript are in PHP Files.

Sarge

Let me chime in before this topic gets out of hand...

On most servers, you can use PHP code inside an HTML page. What happens is (a bit simplified, but basically correct):

1. Someone wants to visit a page of your site, using a browser.
2. The browser sends the URL of the page to the server of the site.
3. Apache (or IIS, or Lighttpd, or whatever webserver is running on the server) reads the requested HTML page from the server's storage.
4. If Apache finds PHP code in the page, it sends everything between <?php and ?> to PHP.
5. PHP parses the code and returns the result as HTML to Apache.
6. Apache returns the result, along with the rest of the HTML code of your page, to the visitor's browser.

Let me repeat: PHP code should work inside an HTML page if the server is configured to do that, and most commercial servers are. If you're not sure about this, ask your host.

Dragooon, what you have said can be true, but not in all servers. So please test your statements before posting...

Now, John, your code had a few typos. Try this:


<p>Please have a look, enjoy, participate, and come back soon . . . John, Webmaster.</p>

<?php
require("/home/jlsr12/public_html/forum/SSI.php");

$array ssi_recentTopics(10null'array');
   foreach (
$array as $recent)
   {
      echo 
'
      <a href="'
$recent['href'], '" title="Board: '$recent['board']['name'], ' - Poster: '$recent['poster']['name'], '">
      '
$recent['subject'], '
      '
$recent['new'] ? '' '<a href="' $scripturl '?topic=' $recent['topic'] . '.msg' $recent['new_from'] . ';topicseen#new"><img src="' $settings['images_url'] . '/' $context['user']['language'] . '/new.gif" alt="' $txt[302] . '" border="0" /></a>''
      '
$recent['preview'], '
      </a><br/>'
;
   }
?>


</td>

    Please do not PM me with support requests unless I invite you to.

http://www.zeriyt.com/   ~   http://www.galeriashqiptare.net/


Quote
<H> I had zero posts when I started posting

Cheese Head

#18
Thanks Dragooon for all your patience and thanks Sarge on taking the extra effort to explain and to correct my code.

Sarge, I just updated my default.htm homepage with your code and FTP'd to my host called www.hostgator.com but sadly it doesn't display anything.

I haven't checked but I'm pretty sure they use Apache? They don't mention it on their features page http://www.hostgator.com/shared.shtml, but they show an Apache Handlers feature button on my cPanel and on their example cPanel at http://67.18.39.34:2082/frontend/x/index.html.

Sorry for asking for more support, appreciate if you have a couple minutes to advise . . . thanks John.

Sarge

Have you asked the HostGator support about whether PHP code inside an HTML file should work in your account?

Also, make sure that the path to SSI.php is correct.

    Please do not PM me with support requests unless I invite you to.

http://www.zeriyt.com/   ~   http://www.galeriashqiptare.net/


Quote
<H> I had zero posts when I started posting

Advertisement: