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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,973
  • Latest: NonStop
Stats
  • Total Posts: 196,231
  • Total Topics: 21,353
  • Online today: 515
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 191
  • Total: 191

Pulling forum post to front page

Started by jawd, August 03, 2006, 10:59:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jawd

Ok folks, sorry to ask this.  Ive spent ages readng through the block snippets but I just cant lay my hands on what Im after!

Basically, Im just getting to grips with blocks and such.  What I have in my forum is a few boards.  A couple of the boards have child boards called "news".  I will post news as a new topic in each of these boards.  Id like to be able to show the posts I do (not the replies, so first posts only), from each of these news sections on the front page.  If it was a long post, it may also have a link at the end saying "read more" or something to that effect.

For example it could look like:

Latest News:

Section 1

News article here .......................... read more (link to forum post)

Section 2

News article here .......................... read more (link to forum post)

Section 3

News article here .......................... read more (link to forum post)

:-\

I think it is possible but just really need nudging in the direction of where I might get the code from.

Thanks in advance,


iwyen

You'll need to create a phpbox and in it, use SMF's SSI functions to call those posts. I'm half awake and have no access to SMF a.t.m. so I can't help with the coding now. I'll check back later if nobody comes along to throw in the codes  :P

hygron

I am attempting the same type of read more links at my site, so I'll be following this thread ...peace

iwyen

Hi jawd, I'll just assume that you're new to SMF. SMF has some functions stored on SSI.php (do not edit at any point in time! unless you know what you're doing and can remember what you've done) that allows us to display pretty much information. The examples can be seen through calling ssi_examples.php.

http://www.tinyportal.net/smf/ssi_examples.php

More info here:
http://www.simplemachines.org/community/index.php?topic=14906.0

In your case, I'll use ssi_boardNews. To use it as it is (default), create a phpbox and drop in this line:

ssi_boardNews();

Follow this tutorial to learn how to cater to your needs:
http://www.simplemachines.org/community/index.php?topic=13016.0

To specify some conditions (specific), use this line instead:

ssi_boardNews($board = null, $limit = null, $start = null, $length = null, $output_method = 'echo')

Change $board to your child board's number, $limit to how many post to show and $length to how many characters to show.

The xx Comments brings readers to the actual post. If you want to change it to Read More ..., you'll need to change more codes (customized)!!

1. Open SSI.php and look for:
function ssi_boardNews($board = null, $limit = null, $start = null, $length = null, $output_method = 'echo')


2. Copy the whole function into your phpbox block. It's a whole chunk so I'm not posting the full code here.

3. Rename ssi_boardNews to something else, say ssi_boardNews1 or ssi_boardNews_child1.

4. Change to TP's Read More... Look for:

'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['numReplies'] . ' ' . ($row['numReplies'] == 1 ? $txt['smf_news_1'] : $txt['smf_news_2']) . '</a>',


And change to:

'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $txt['tp-readmore'] . '</a>',


5. Look for:

', $news['link'], $news['locked'] ? '' : ' | ' . $news['comment_link'], '


I honestly have no idea how to read this... but change it to:


', $news['link'],'



6. Remember to call for it:

ssi_boardNews_child1();

if you already specify your board, etc. in the codes, or

ssi_boardNews_child1($board = xx.0, $limit = xx, $start = null, $length = xxx, $output_method = 'echo')

if you have not specify.

7. If you want to modify the appearance further, take a look at the codes that comes after:

foreach ($return as $news)

8. Once you're happy with it, duplicate the whole function for ssi_boardNews_child2 and ssi_boardNews_child3. How you want to display them is really up to you.


echo 'This is my first child:<br/>';
ssi_boardNews_child1()<br/>;
echo 'This is my second child:<br/>';
ssi_boardNews_child2()<br/>;
echo 'This is my third child:<br/>';
ssi_boardNews_child3();


Lastly, phew, I've gave it a try and it's working fine  :)

iwyen

Quote from: hygron on August 04, 2006, 05:31:21 AM
I am attempting the same type of read more links at my site, so I'll be following this thread ...peace

Hi Hygron,

In case I got you wrong, these instructions are for showing forum posts from a certain forum board and the read more link will point users to the thread.

Hope it helps :)

jawd

Many thanks for that.  works great!  and yes, I am new to all this :D

iwyen


hygron

thanks for the heads-up...I am just trying to suck-up all the knowledge I can...peace

jawd

Hi again, run into a small issue.  I've tried adding three blocks in total.  This so I can show latest nes from three different boards.  The first one worked like a charm and Ive been playing around with it no problem.  the second two show the block title, but havent pulled the posts across.  All I done was copy and paste the code from the first working block to the next two.  I then changed the value for the board number.  Ive since checked and double checked and I did get these numbers right, and they do have posts in them.

Any idea's what Ive overlooked?

Thanks,

iwyen

Oh.. You want 3 blocks.. Did you change the function name (child1, 2, 3) and call for the right one for each one?

Alternatively, you can put all 3 blocks into one block, and you'll need the function code only once and save some work on your database :) Just need a little more code to make them look like 3 blocks. Of course not recommended if you want to move or on/off them too often :)

This website is proudly hosted on Crocweb Cloud Website Hosting.