collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 383
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Installation errors? Mod incompatibilities? Upgrade problems? Make your way over to the Install and Upgrade Support board for all your solutions!

Author Topic: IF-statement targeting the front/portal page?  (Read 5655 times)

0 Members and 1 Guest are viewing this topic.

Offline Tarista

  • Semi Newbie
  • *
  • Posts: 37
  • SMF Version: 2.0.10
  • SP Version: 2.3.5
IF-statement targeting the front/portal page?
« on: June 18, 2014, 02:34:31 PM »
Hi,

I'm using the code below inside a custom php block to target a second inactive block loaded inside it and different depending on circumstances.
Now I want to add (1) one which targets the portal page / frontpage only and (2) one which shows only on the simpleportal pages. The second I can image would be something along the lines of current_action == page, but regarding the frontpage I don't know, there is no action in the url.

Thank you! :)

edit: Seems 'page' doesn't work, or I'm writing it incorrectly.
I know I can add a block that displays on all (sp_)pages but I have it written all in the same custom block and would like to have it that way if possible :)

Also, the block is visible only on Portal and the (Simple Portal) Pages, so it would be enough/workable if I could either use the statement to hide it on Portal OR Show it only on Pages if it's too complicated to make two statements :)

The code is from you guys originally, I have just modified it a bit. Here it show on board 5 but I would like to change it as described above.
Code: [Select]
global $context;
if ((empty($context['current_action']) && empty($context['current_topic']) && isset($context['current_board']) && $context['current_board'] == 5) || (isset($context['current_action']) && ($context['current_action'] == 'post' || $context['current_action'] == 'post2' || empty($context['current_topic'])) && isset($context['current_board']) && $context['current_board'] == 5))
{
-Displays on board 5-
}
« Last Edit: June 18, 2014, 05:12:33 PM by Tarista »

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: IF-statement targeting the front/portal page?
« Reply #1 on: June 26, 2014, 04:05:16 PM »
The portal page is the page with no actions, no boards, no pages, nothing whatsoever.
In index.php, it is found by process of elimination.  When simpleportal is NOT installed, SMF does boardindex when nothing else is going on.

and you are correct that page is not an action.  You can go right to the query string to see if 'page' is one of the query string variables  --
isset($_GET['page']) && (! empty($_GET['page']))
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline Tarista

  • Semi Newbie
  • *
  • Posts: 37
  • SMF Version: 2.0.10
  • SP Version: 2.3.5
Re: IF-statement targeting the front/portal page?
« Reply #2 on: June 27, 2014, 11:10:24 AM »
That makes sense. Might be hard to target it then, and for my purpose not actually necessary. :)

I got it working by using the code you mentioned instead. :D Thank you!
I am not familiar with using query string variables to check like that, I guess that something you learn after a while. Not sure how it actually works and where the query strings are defined, but Hey, it works :D

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: IF-statement targeting the front/portal page?
« Reply #3 on: June 27, 2014, 12:43:13 PM »
Php provides GET variables for you.  SMF tries to make them safe for you.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline Tarista

  • Semi Newbie
  • *
  • Posts: 37
  • SMF Version: 2.0.10
  • SP Version: 2.3.5
Re: IF-statement targeting the front/portal page?
« Reply #4 on: June 27, 2014, 12:48:33 PM »
Sounds reasonable :) And the above code is safe, correct? I understand the choice of words but  I'm just double-checking to make sure since you said tries.

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: IF-statement targeting the front/portal page?
« Reply #5 on: June 27, 2014, 01:15:53 PM »
I am not a dev.  So you should talk to a REAL SMF dev for a better understanding of how SMF sanitizes the query string, and what dangers that can and cannot leave behind.

That said, and remember I am not a dev, since you are not actually trying to use the value of the get variable, you are not at much risk for the contents of it.

The most important thing is that, whatever code you write, if you are going to show some content, that you do not circumvent or skip the code that is always checking whether the user is allowed to see or do whatever the URL says they want to try to do.  So if you look at simpleportal code, before it serves a block or page, it checks that the person is allowed to see it.

You are probably not doing this, but I don't see your code so I don't know what you are trying to do.

And I am not a dev, so I would be very slow and unsure of myself checking for security problems.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline Tarista

  • Semi Newbie
  • *
  • Posts: 37
  • SMF Version: 2.0.10
  • SP Version: 2.3.5
Re: IF-statement targeting the front/portal page?
« Reply #6 on: June 27, 2014, 01:40:56 PM »
Thank you for that answer :) It makes sense what you are telling me and I do understand that you cannot tell me it's completely safe because you can't know that for sure :)

I can't see that what I'm trying to do is creating a problem. So I hope not.

I'm using the code from a thread here to display a couple of deactivated blocks containing BBC-code. I need to use PHP around it to style it and have some of them randomized. I use the code from above so some display on the portal page and some only on simpleportal pages.

All my logged in members can see the BBC-blocks and only a logged in user can see the PHP block which contains the code (so the check should be there atleast). I've build a special left-side menu of content in one php-block so to speak so that my moderator can change the content in the menu around using the BBC-blocks I load into it. If that makes any sense at all. :)

That was the easiest way to get the design to work for us and for it to be user-friendly to my moderators.

So I'm not using it outside of SMF or the portal, I'm actually using it inside the portal and only to display some BBC-styled text content :) And from what I understand reading your reply that should be fine. :)


Code: (this is what I'm using) [Select]
global $context;
if (isset($_GET['page']) && (! empty($_GET['page'])))
{
echo '<div class="sp_leftStyle">';

$block = current(getBlockInfo(false, 26, false, false));  // Load block info
$block['style'] = sportal_parse_style('explode', $block['style'], true);  //Parse block style parameters.
template_block($block); // Output the block.
echo '</div>';
« Last Edit: June 27, 2014, 01:44:57 PM by Tarista »

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: IF-statement targeting the front/portal page?
« Reply #7 on: June 29, 2014, 09:33:09 PM »
Yep.  I'm just cautioning you to use the standard SMF and simpleportal ways of checking permission, and to ask experienced SMF devs for advice about all that.

How is your little project going?
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline Tarista

  • Semi Newbie
  • *
  • Posts: 37
  • SMF Version: 2.0.10
  • SP Version: 2.3.5
Re: IF-statement targeting the front/portal page?
« Reply #8 on: July 25, 2014, 07:31:57 AM »
I'm sorry for the late reply, it's vacation time for me so I have been away for a while.

It's going well though :) Thank you for the replies and the information. I will be careful what I do, security is of course a high concern of mine.

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: IF-statement targeting the front/portal page?
« Reply #9 on: September 23, 2015, 07:09:38 PM »
I'm just going through some old topics, and thought it would be nice to mention that the action you're looking for is 'home' as SMF is separated into 'forum'. You can also use 'portal'.

Eg,

Code: [Select]
if ($context['current_action'] == 'home')
     echo 'This only is showing on the home page!';