News: September 21st, 2019, The Tinyportal team is pleased to announce the release of ~~ TinyPortal 1.6.4! GET IT NOW!!!

Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media
Welcome, Guest. Please login or register.
Did you miss your activation email?

December 10, 2019, 09:01:48 PM

Login with username, password and session length

Recent

Members
Stats
  • Total Posts: 189279
  • Total Topics: 20775
  • Online Today: 386
  • Online Ever: 629
  • (November 08, 2018, 01:36:54 PM)
Users Online
Users: 0
Guests: 39
Total: 39

Author Topic: How to check if you're user is on the frontpage?  (Read 2215 times)

0 Members and 1 Guest are viewing this topic.

Offline Heero

  • Jr. Member
  • **
  • Posts: 19
How to check if you're user is on the frontpage?
« on: August 11, 2010, 06:34:16 PM »
Well hi,

I am here with another question.
I'd like to code something in my index.template.php.

I would like to show an image in the top of my page when I am on the frontpage, but not in any other action or page.
There exists a check like "if ($context['current_action'] == 'myaction')".
However, that one doesn't work I guess, what would I need for the frontpage?
Thanks in advance!
« Last Edit: August 12, 2010, 07:06:58 PM by ZarPrime »

Offline Lesmond

  • Do what you have to!
  • Administrator
  • *
  • Posts: 3129
    • Tiny Pix... Free Image Hosting and Sharing.
Re: How to check if you're user is on the frontpage?
« Reply #1 on: August 12, 2010, 03:49:06 AM »
Not knowing what set up you have, it would help if you could give us the info in the Posting Guidelines this can also be found in the post/reply page.
Please don't PM me for support without an invitation.


Offline IchBin™

  • Developer
  • *
  • Posts: 16228
    • My Website
Re: How to check if you're user is on the frontpage?
« Reply #2 on: August 12, 2010, 07:29:24 AM »
I think $context['TPortal']['is_frontpage'] is what you're looking for.

Tip:
When you want to know what is available you can use a couple of functions in PHP to see this:

vardump() or print_r(). I usually do it like this at the bottom of my page in a block to see what is in $context.
echo '<pre>'print_r($context['TPortal']) ,'</pre>';

Offline Heero

  • Jr. Member
  • **
  • Posts: 19
Re: How to check if you're user is on the frontpage?
« Reply #3 on: August 12, 2010, 12:04:31 PM »
At Lesmond: Well the set up wasn't really necessary since it was a coding question :)
There isn't a forum about coding I believe..

@ IchBin: thanks, that's exactly what I am searching for!

Offline ZarPrime

  • Friends
  • *
  • Posts: 4653
Re: How to check if you're user is on the frontpage?
« Reply #4 on: August 12, 2010, 07:06:30 PM »
Heero,

Actually, Lesmond's request for the information contained in the posting guidelines was indeed necessary since coding for SMF 2.0 is drastically different that coding for previous versions of SMF.  In any case, since there is no Coding Forum per se, this topic would be better placed into the Support Forum than the International Forum and I will move it there now and mark the topic solved.

ZarPrime

Offline Heero

  • Jr. Member
  • **
  • Posts: 19
Re: How to check if you're user is on the frontpage?
« Reply #5 on: August 13, 2010, 12:44:11 PM »
Oh like that, I am sorry.
Also, it bugs.
In stuff like mypage.com/index.php?topic=30 it also shows the echo.
Or is that normal?

I am using SMF 2.0 RC3 & TinyPortal 1.0 beta 5.2.

Offline ZarPrime

  • Friends
  • *
  • Posts: 4653
Re: How to check if you're user is on the frontpage?
« Reply #6 on: August 13, 2010, 06:49:24 PM »
I'm not sure that anyone understands your last question.  Can you post a link to an example and perhaps explain that last question a little better?

ZarPrime

Offline Heero

  • Jr. Member
  • **
  • Posts: 19
Re: How to check if you're user is on the frontpage?
« Reply #7 on: August 21, 2010, 09:54:28 AM »
I am sorry for the late reply, was a bit busy last days :-).

And giving an example is hard but I'll try to explain better.

I would like to show an image when I am on the portal main.
Example: http://www.tinyportal.net/index.php --> this is the portal its main of the tiny portal support website.
Using the code which IchBin provided, it works. But not for each section of the website.
When I am checking topics in a board the image still shows up, which it shouldn't.
Example: http://www.tinyportal.net/index.php?board=25.0 --> the image would also be shown here.

My question is how to fix this since only the portal main should contain it.
Thanks in advance!

Offline ZarPrime

  • Friends
  • *
  • Posts: 4653
Re: How to check if you're user is on the frontpage?
« Reply #8 on: August 22, 2010, 08:48:55 AM »
Heero,

I'm not quite sure just exactly what you are trying to do but TinyPortal will let you put a picture just on the FrontPage just by placing it into a block in the panel of your choice.  You can easily set this block to show only on the FrontPage and no place else.

For instance, I just placed a block into the upper panel on my test site that has a picture of some of the old TinyPortal Team.  That block is set to show only on the FrontPage and you can see it here, at least for awhile --> http://talesofthehavenexpanse.com/smf2test/index.php

ZarPrime

Offline Heero

  • Jr. Member
  • **
  • Posts: 19
Re: How to check if you're user is on the frontpage?
« Reply #9 on: August 22, 2010, 12:09:45 PM »
Thanks for your reply, I appreciate your help a lot.
But I finally found the code how to make it work properly.

It would be:
if ($context['TPortal']['is_frontpage'] != !empty($context['current_board']))

in order to show content on the frontpage and not on other pages as for example in boards.