Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
coding-topic
Check if is groupView
Avatar
Focus97
Member
Free Members
sp_UserOfflineSmall Offline
Apr 12, 2012 - 5:58 pm

Curious if this is easy or...a pain. I want to run a conditional in spHead.php to check if it's the GroupView. Reason being, in the spGroupView.php file, I'm running the search functionality below a custom part of that page. Problem is, the search feature is run in spHead.php as well.

 

I'd like to declare a conditional, like WordPress' "is_page()", that detects if it's the groupView, and if so, don't show the search feature. 

 

Is this possible via a template tag? I see in the wiki an sp_is_groupview. Please, oh, please tell me it'll do what I want?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 12, 2012 - 9:30 pm

yes, of course! wink

see our codex:  http://codex.simple-press.com/.....functions/

the Primitives section...

you will see checks for different types of page views... we are still in the process of populating those pages with detailed info...

but usage for your example is quite simple:

if (sp_is_groupview()) {
    # do group view stuff
} else {
    # do other page stuff
}

alternatively, a little less clean, but you could look at a global array $sfvars and the 'pageview' element...  but nicer to use the API...

Avatar
Brandon
U.S.
SP Wrangler
Free Members
sp_UserOfflineSmall Offline
Apr 12, 2012 - 9:40 pm

Another option is to create a special header file for group view.

In the groupview php file you will see it loads sphead.php first. Create a copy of sphead.php, edit out or change what you want and save it as something like spGroupHead.php.

The change groupview.php to use it instead of sphead.php.

Avatar
Focus97
Member
Free Members
sp_UserOfflineSmall Offline
Apr 13, 2012 - 11:26 am

Both awesome suggestions. I didn't think of the latter, which is genius. Wanting to keep files to a minimum (no reason other than I prefer minimalist setup), I went with the sp_is_groupview(). Worked beautifully!

Thanks to the both of you.

We're building it on http://www.ornishspectrum.com. Once all the dev is done, we'll be opening up the forum (likely next week) and I'll enter it in the "show your stuff" area.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Apr 13, 2012 - 11:57 am

Glad it worked for you

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626