TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,026
  • Total Topics: 21,333
  • Online today: 916
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 263
  • Total: 264
  • lurkalot

Using Snippets 1 folder above forum ?

Started by greenman, December 20, 2006, 09:43:52 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

greenman

Can someone please help me out here, I can't seem to make it work.

What I'm trying to do:
Place a box on my website showing results from the forum which is in folder "forum". (main/forum)

Like for exactly using this code:
<?php $result=ssi_recentTopics(10,array(1,3,4),'return');
echo
'<center>';
echo 
'<list>';
foreach(
$result as $my){ 
echo 
'<li>'.$my['link'].'</li>'; 
}
echo 
'</list>';
echo
'</center>';
echo 
'<span class="smalltext">SmallText</span>'; ?>



So how can I point inward into the forum board?


Thank You. :)

JPDeni

I'm not following you.

QuotePlace a box on my website ...
Is this a block within TP or something outside of TP and SMF?

Quotefrom the forum which is in folder "forum". (main/forum)
??? I don't know about using folders.

Can you give me an example of the structure of your site and exactly what you want to accomplish?

G6Cad

Are you talking about the recent posts from the forum ?
If so, there are premade blocks in the block settings called "recent block"

greenman

Sorry for the poor description, I meant on a page outside of SMF & TP, a page in PHP, which is located 1 folder up from the SMF forum.

So what I want to do is place the information on the page, to display the recent posts of a specific board.


Is it even possible? ???

JPDeni

Yes, it's possible. It's not a TinyPortal problem, but it shouldn't be too hard to work it out.

Your code looks fine, but you have to load in the SSI.php file before you can call the functions. Something like

<?php

require("forum/SSI.php");



and so on with the rest of you code. Change "forum" above to the directory where your SMF installation is. You might have to put in the whole path (not url!) to the SSI.php file, but try the relative path first and see if that works.

greenman

Awesome, works perfectly, thanks. :)

didn't know "require" even existed. :P

jacortina

That's what the SSI is for (in general). Note that the ssi_recentPosts and ssi_recentTopics functions both natively work on an 'exclude list of boards' basis, but I know that others have added copies of the functions to the SSI.php which work on an 'include from list only' basis. This is very much more a matter for the SimpleMachines forum, though.

This post, in fact, gives the function you want to add to your SSI.php:
http://www.simplemachines.org/community/index.php?topic=116848.msg750946#msg750946

You can get an idea of using the SSI functions by entering in your browser address bar:
http://<your web address>/forum/ssi_examples.php

greenman


jacortina

That code has to be added to the SSI.php in the top directory/folder of your forum. Insert it just before the ending "?>" in the file. It will define a new SSI function called ssi_recentTopicsInBoard. You'd call it just like you would other ssi functions.


Assuming you want the 10 most recently posted to topics in board #2 (seeing as that's the obvious absence in your list of boards to EXCLUDE in the example above):

ssi_recentTopicsInBoard(10, array(2), 'return')

[I thought that third argument was supposed to contain the word 'array' if an array was going to be returned; but then, I don't use SSI that much.]

The benefit of doing it by board inclusion is that you don't have to keep adding to the list of boards to exclude when you add more boards.

greenman

hmm... That's what I thought, but doesn't show anything, at all.

<?php
require("forum/SSI.php");
$result=ssi_recentTopicsInBoard(10,array(6),'return');
foreach(
$result as $my){ 
echo 
'<b>- </b>'.$my['link'].'<br />'; 
}
?>


And actually it's board 6 that i'd like to be used.

I tried other boards, more popular and less popular, still absolutely nothing. And I didn't edit the code I put in the SSI.php, so if I had to edit something there that would be the problem?

This website is proudly hosted on Crocweb Cloud Website Hosting.