Simple Machines Community Forum

SMF Support => SMF 2.1.x Support => Topic started by: gear777 on May 20, 2024, 04:33:24 PM

Title: only on front page
Post by: gear777 on May 20, 2024, 04:33:24 PM
Hello guys, I need help with this. How can I only show something in the front page?

this is a example:
if ($url == '/index.php'){
echo 'hello world';
}elseif($url == '/index.php?board=4.0'){
echo 'Hello night';
}
Title: Re: only on front page
Post by: Arantor on May 20, 2024, 04:51:03 PM
Where exactly do you want to put this content? (it matters relative to the front page listing)

Also are you using any of the portal mods?
Title: Re: only on front page
Post by: TwitchisMental on May 20, 2024, 04:52:29 PM
What is it that you are trying to show on the front page?  You could simply add it is to the board index.template.php.  Or if using a portal mod you could make a custom block and set it to only show on the board index.
EDIT : Arantor beat me to it lol
Title: Re: only on front page
Post by: gear777 on May 20, 2024, 05:10:17 PM
Quote from: Arantor on May 20, 2024, 04:51:03 PMWhere exactly do you want to put this content? (it matters relative to the front page listing)

Also are you using any of the portal mods?
Quote from: TwitchisMental on May 20, 2024, 04:52:29 PMWhat is it that you are trying to show on the front page?  You could simply add it is to the board index.template.php.  Or if using a portal mod you could make a custom block and set it to only show on the board index.
EDIT : Arantor beat me to it lol
I want to add a list of topics on the top of boards, but it's show on every page as topics or user page.
Title: Re: only on front page
Post by: Kindred on May 20, 2024, 05:12:30 PM
But, To be clear the code you have proposed will not do it.

Where did you add that code?

And, please answer the other questions
Title: Re: only on front page
Post by: gear777 on May 20, 2024, 05:58:31 PM
Quote from: Kindred on May 20, 2024, 05:12:30 PMBut, To be clear the code you have proposed will not do it.

Where did you add that code?

And, please answer the other questions
This is something I want to on the front page:
require_once('SSI.php');
$PostList = ssi_recentTopics(8, null, null, 'array');
foreach ($PostList as $Post) {

echo "<tr>";
echo "<div class='forum_posts'>";
echo '<br><td width="350px"><a target="_blank" href=', $Post['href'], '>', $Post['subject'], '</a></td>',
'<td width="350px"><a target="_blank" href=', $Post['href'], '>', $Post['board']['id'], '</a></td>',
'<td width="250px"><a target="_blank" href=', $Post['board']['href'], '>',$Post['board']['name'],'</a></td>',
'<td width="100px"><a target="_blank" href=', $Post['poster']['href'], '>', $Post['poster']['name'], '</a></td>',
'<td width="150px">',$Post['time'],'</td>';

echo "</div>";
echo "</tr>";
}
unset($PostList);
}
I only want to show on front page, I added in index.template.php
Title: Re: only on front page
Post by: Arantor on May 20, 2024, 06:42:43 PM
Well, first things first, index.template.php is on every page - if you want it on the board index, put it in Boardindex.template.php which is the template for the front page.

Secondly, you're not *really* supposed to use SSI.php inside SMF itself. Yes, it'll work, but it will likely introduce other issues. A better solution is to actually use one of the portal mods which come with a recent topics block to put at the top on any page you want.
Title: Re: only on front page
Post by: Kindred on May 20, 2024, 08:41:50 PM
Also,  forcing a pixel width like that is so 10 years ago... it's bad coding in current designs. Plus, I see tr and td, but no table...
But then again,  using a table for layout is also last decade
Title: Re: only on front page
Post by: Arantor on May 21, 2024, 04:24:28 AM
It's literally tabular data though.
Title: Re: only on front page
Post by: Kindred on May 21, 2024, 10:03:07 AM
Quote from: Arantor on May 21, 2024, 04:24:28 AMIt's literally tabular data though.
I guess it COULD be considered tabular data...   :P
Title: Re: only on front page
Post by: gear777 on May 21, 2024, 11:53:48 AM
Quote from: Arantor on May 20, 2024, 06:42:43 PMWell, first things first, index.template.php is on every page - if you want it on the board index, put it in Boardindex.template.php which is the template for the front page.

Secondly, you're not *really* supposed to use SSI.php inside SMF itself. Yes, it'll work, but it will likely introduce other issues. A better solution is to actually use one of the portal mods which come with a recent topics block to put at the top on any page you want.
Thanks! all set. I have another question. Could I pull the user avatar from SSI.php?
Title: Re: only on front page
Post by: Arantor on May 21, 2024, 12:51:27 PM
Pretty sure it doesn't support avatars, and even if it did, you're still not *really* supposed to be using it like that...
Title: Re: only on front page
Post by: gear777 on May 21, 2024, 12:55:42 PM
Quote from: Arantor on May 21, 2024, 12:51:27 PMPretty sure it doesn't support avatars, and even if it did, you're still not *really* supposed to be using it like that...
Thanks. I really appreciate it.
Title: Re: only on front page
Post by: Kindred on May 21, 2024, 08:22:16 PM
Ti reiterate what arantor said...  don't use SSI within existing forum template files.  Really.  Don't do that.

There are other, better ways to do what you are looking to do without purposefully misusing the scripts