Advertisement:

Author Topic: Index/Default Dynamic Forum Content  (Read 13076 times)

Offline Cheese Head

  • Jr. Member
  • **
  • Posts: 166
  • Gender: Male
    • www.CheeseForum.org
Index/Default Dynamic Forum Content
« on: February 10, 2008, 07:45:03 AM »
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.

Offline Dragooon

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 6,738
  • Gender: Male
  • I'm bIn
    • ShitizGarg on Facebook
    • Dragooon on GitHub
    • dragooon on LinkedIn
    • SMF-Media
Re: Index/Default Dynamic Forum Content
« Reply #1 on: February 10, 2008, 08:13:41 AM »
So you want a homepage type of thing?

Offline Cheese Head

  • Jr. Member
  • **
  • Posts: 166
  • Gender: Male
    • www.CheeseForum.org
Re: Index/Default Dynamic Forum Content
« Reply #2 on: February 10, 2008, 08:48:32 AM »
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.

Offline karlbenson

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,629
  • Gender: Male
    • Criminal Brief UK

Offline Cheese Head

  • Jr. Member
  • **
  • Posts: 166
  • Gender: Male
    • www.CheeseForum.org
Re: Index/Default Dynamic Forum Content
« Reply #4 on: February 10, 2008, 04:31:52 PM »
Thanks karlbenson, appreciate, wish me luck, John.

Offline Cheese Head

  • Jr. Member
  • **
  • Posts: 166
  • Gender: Male
    • www.CheeseForum.org
Index/Default Dynamic Forum Content
« Reply #5 on: May 18, 2008, 09:27:32 AM »
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.
« Last Edit: May 18, 2008, 09:58:15 AM by Cheese Head »

Offline Sarge

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 6,209
  • Gender: Male
    • Zëri YT!
Re: Index/Default Dynamic Forum Content
« Reply #6 on: May 18, 2008, 10:31:32 AM »
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

Offline Cheese Head

  • Jr. Member
  • **
  • Posts: 166
  • Gender: Male
    • www.CheeseForum.org
Re: Index/Default Dynamic Forum Content
« Reply #7 on: May 24, 2008, 08:10:50 AM »
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.
« Last Edit: May 24, 2008, 08:13:56 AM by Cheese Head »

Offline Dragooon

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 6,738
  • Gender: Male
  • I'm bIn
    • ShitizGarg on Facebook
    • Dragooon on GitHub
    • dragooon on LinkedIn
    • SMF-Media
Re: Index/Default Dynamic Forum Content
« Reply #8 on: May 24, 2008, 08:12:59 AM »
It should be a .php File not .htm or .html

Offline Cheese Head

  • Jr. Member
  • **
  • Posts: 166
  • Gender: Male
    • www.CheeseForum.org
Re: Index/Default Dynamic Forum Content
« Reply #9 on: May 24, 2008, 08:19:31 AM »
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?

Offline Dragooon

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 6,738
  • Gender: Male
  • I'm bIn
    • ShitizGarg on Facebook
    • Dragooon on GitHub
    • dragooon on LinkedIn
    • SMF-Media
Re: Index/Default Dynamic Forum Content
« Reply #10 on: May 24, 2008, 08:29:37 AM »
You can do it this way
<?php
echo 'YOUR HTML HERE';
?>

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

Offline Cheese Head

  • Jr. Member
  • **
  • Posts: 166
  • Gender: Male
    • www.CheeseForum.org
Re: Index/Default Dynamic Forum Content
« Reply #11 on: May 24, 2008, 08:58:39 AM »
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 . . .

Offline Dragooon

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 6,738
  • Gender: Male
  • I'm bIn
    • ShitizGarg on Facebook
    • Dragooon on GitHub
    • dragooon on LinkedIn
    • SMF-Media
Re: Index/Default Dynamic Forum Content
« Reply #12 on: May 24, 2008, 09:08:07 AM »
You cannot use SSI in HTML(not directly atleast). You will be needing to either use SHTML or PHP(recommended).

Offline Cheese Head

  • Jr. Member
  • **
  • Posts: 166
  • Gender: Male
    • www.CheeseForum.org
Re: Index/Default Dynamic Forum Content
« Reply #13 on: May 24, 2008, 09:41:36 AM »
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?

Offline Dragooon

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 6,738
  • Gender: Male
  • I'm bIn
    • ShitizGarg on Facebook
    • Dragooon on GitHub
    • dragooon on LinkedIn
    • SMF-Media
Re: Index/Default Dynamic Forum Content
« Reply #14 on: May 24, 2008, 10:08:10 AM »
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.

Offline Cheese Head

  • Jr. Member
  • **
  • Posts: 166
  • Gender: Male
    • www.CheeseForum.org
Re: Index/Default Dynamic Forum Content
« Reply #15 on: May 24, 2008, 10:54:07 AM »
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 . . .

Offline Dragooon

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 6,738
  • Gender: Male
  • I'm bIn
    • ShitizGarg on Facebook
    • Dragooon on GitHub
    • dragooon on LinkedIn
    • SMF-Media
Re: Index/Default Dynamic Forum Content
« Reply #16 on: May 24, 2008, 10:59:23 AM »
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
Code: [Select]
<?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.

Offline Sarge

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 6,209
  • Gender: Male
    • Zëri YT!
Re: Index/Default Dynamic Forum Content
« Reply #17 on: May 25, 2008, 09:01:59 AM »
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:

Code: [Select]
<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

Offline Cheese Head

  • Jr. Member
  • **
  • Posts: 166
  • Gender: Male
    • www.CheeseForum.org
Re: Index/Default Dynamic Forum Content
« Reply #18 on: May 26, 2008, 03:19:52 PM »
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.
« Last Edit: May 26, 2008, 03:27:14 PM by Cheese Head »

Offline Sarge

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 6,209
  • Gender: Male
    • Zëri YT!
Re: Index/Default Dynamic Forum Content
« Reply #19 on: May 30, 2008, 01:37:57 PM »
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