News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

only on front page

Started by gear777, May 20, 2024, 04:33:24 PM

Previous topic - Next topic

gear777

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';
}

Arantor

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?
Holder of controversial views, all of which my own.

TwitchisMental

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

gear777

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.

Kindred

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
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

gear777

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

Arantor

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.
Holder of controversial views, all of which my own.

Kindred

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
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

It's literally tabular data though.
Holder of controversial views, all of which my own.

Kindred

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
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

gear777

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?

Arantor

Pretty sure it doesn't support avatars, and even if it did, you're still not *really* supposed to be using it like that...
Holder of controversial views, all of which my own.

gear777

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.

Kindred

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
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: