Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: samborabora - elokuu 10, 2014, 01:55:54 IP

Otsikko: Current area= check?
Kirjoitti: samborabora - elokuu 10, 2014, 01:55:54 IP
I want to make sure something only displays if it's not on a certain area (I want the error to display UNDER a part of the profile edit code, so it's down in the profile edit part as well as function template_profile_above(), but so I don't get two messages displaying, I want to not have it display in function template_profile_above() if we are currently under area=forumprofile).

So, I was thinking:
// If an error occurred while trying to save previously, give the user a clue!
if (!empty($context['post_errors']) && $context['section'] !== 'forumprofile')
echo '
', template_error_message();

// If the profile was update successfully, let the user know this.
if (!empty($context['profile_updated']) && $context['section'] !== 'forumprofile')
echo '
<div id="profile_success">
', $context['profile_updated'], '
</div>'
;


Might work, but I guess $context['section'] !== 'forumprofile' isn't too much of a thing. I also tried $context['areas'] !== 'forumprofile' and that didn't help. Which is the proper way to check for which area we are under?

PS: I assumed it would have worked like $context['folder'] !== 'sent' or $context['folder'] !== 'inbox' does?
Otsikko: Re: Current area= check?
Kirjoitti: Arantor - elokuu 10, 2014, 02:32:12 IP
Why does it have to be in the template_profile_above when you could just put it in the area of the profile you're displaying it in?
Otsikko: Re: Current area= check?
Kirjoitti: samborabora - elokuu 10, 2014, 03:07:54 IP
I did also, but I presumed that part would need to remain in the header also in case anything else relies on it that wasn't related to the profile edit sections. Or I could just put it in every section, but I was gonna use the profile header as a blanket for everything that wasn't profile edit.

If that makes sense?

If it isn't relied on by anything else then I might as well just remove it from the header, as you suggest :D
Otsikko: Re: Current area= check?
Kirjoitti: Arantor - elokuu 10, 2014, 03:09:55 IP
I'd say there's not really enough information to make an informed judgement about that, but I do remember that I found myself hating the profile code most of all in SMF, so anything's possible.
Otsikko: Re: Current area= check?
Kirjoitti: samborabora - elokuu 10, 2014, 04:14:01 IP
I'll just take it out of the header and leave it in function template_edit_options() only then :D

Out of interest for possible future use, how DOES one do a check for which area one is currently in?
Otsikko: Re: Current area= check?
Kirjoitti: Arantor - elokuu 10, 2014, 04:49:52 IP
With extreme difficulty. In *theory*, $context['current_area'] should be defined and be correct but it isn't always.
Otsikko: Re: Current area= check?
Kirjoitti: samborabora - elokuu 12, 2014, 08:00:46 AP
Lainaus käyttäjältä: ‽ - elokuu 10, 2014, 04:49:52 IP
With extreme difficulty. In *theory*, $context['current_area'] should be defined and be correct but it isn't always.

Hmm, I thought it might work, but I'm having trouble on the forum profile area. I need to discern between "profile area=forumprofile" and "profile area=account", not sure what the check is?

Tried: if ($context['section'] == 'forumprofile') But it was a no go?
Otsikko: Re: Current area= check?
Kirjoitti: Arantor - elokuu 12, 2014, 08:16:36 AP
In the profile area, try $context['menu_item_selected'].
Otsikko: Re: Current area= check?
Kirjoitti: samborabora - elokuu 12, 2014, 02:08:46 IP
Lainaus käyttäjältä: ‽ - elokuu 12, 2014, 08:16:36 AP
In the profile area, try $context['menu_item_selected'].

Perfect, thankyou!! :D :D