Put quotes around your conditional cases.
eg.
if ($localPhone== Brighton || $localPhone==Test Group)
to:
if ($localNetwork== "Brighton" || $localNetwork=
"Test Group")
See if that works.
[EDIT]
Also $localPhone isn’t defined… you want to use $localNetwork instead.
Thanks for the reply Ray. Yeah i’ve went back too far on my undos. I had it the way you’ve suggested. Any other reason’s why it wouldn’t work, as in logically rather than in my example poor syntax?
I haven’t had time to dive into the logic, but it looks quite sound.
What happens when you echo $localNetwork?
Try bp_get_the_site_group_name() instead of bp_the_site_group_name().
When I have some more time, I might give it another shot.
Hopefully someone else can help you out by then!
I’d also recommend getting acquainted with the bp-groups/bp-groups-templatetags.php.
It’s your bible to BP Groups!
You must use:
bp_get_the_site_group_name()
as without the ‘get’ part, it will echo and not return the value.
Otherwise Andy do you think that should work?
I have tried it, with this code
<?php get_header(); ?>
<div id="content" class="widecolumn">
<h2 class="widgettitle"></h2>
<div id="localphone">
<?php if ( bp_has_site_groups() ) : ?>
<div class="pag-count" id="group-dir-count">
<?php bp_site_groups_pagination_count() ?>
</div>
<div class="pagination-links" id="group-dir-pag">
<?php bp_site_groups_pagination_links() ?>
</div>
<?php while ( bp_site_groups() ) : bp_the_site_group(); ?>
<?php $localPhone = bp_get_the_site_group_name() ?>;
<?php if ($localPhone=
"Manchester" || $localPhone=
"Test Group") {
echo '<dl>';
echo '<dt><a href="http://business-chamber.com/featured-<?php bp_get_the_site_group_name() ?>/" title=""><?php bp_get_the_site_group_avatar_thumb() ?></a></dt>';
echo '<dd><?php bp_get_the_site_group_name() ?></dd>';
echo '</dl>';
} else {
echo 'hello';
}
?>
<?php endwhile; ?>
<?php else: ?>
<div id="message" class="info">
<p><?php _e( 'There were no groups found.', 'buddypress' ) ?></p>
</div>
<?php endif; ?>
</div>
<?php get_footer(); ?>
Im now getting
;
;
hello;
I definately have the 2 test groups there and it is doing something right, as in only returning the hello for the last one where I don’t have a || condition.
<?php $localPhone = bp_get_the_site_group_name() ?>;
Remove the semi-colon from the end and that will get rid of the echo problem.
I assume you meant:
<?php $localPhone = bp_get_the_site_group_name(); ?>
The if statement should be:
<?php if ( ($localPhone=
"Manchester") || ($localPhone=
"Test Group") ) {
Hmmm, thats got rid of the semi colon as you said. Now im just getting the solitary echo as in none of my conditions are satisfied. They should be coz both groups are there. Have i made a mistake regarding the get.
What happens when you try to echo $localPhone?
Along with the corrections that r-a-y points out, I took a quick cursory look and saw this error:
<?php $localNetwork = bp_get_the_site_group_name() ?>;
Should be:
<?php $localNetwork = bp_get_the_site_group_name(); ?>
Thanks for your input Jeff. Ray i get all 3 groups outputting fine when i echo localPhone. Could it be that i need to assign test group to say $testgroup and try the comparison that way? Is there some syntax conflict that won’t let me compare them the way i currently am?
Anyway off to bed now, its 1am uk time.
This could be a little silly and not even note-worthy but try adding spaces between your equals signs:
<?php if ( ($localPhone == "Manchester") || ($localPhone == "Test Group") ) {
The other thing you could do is try just one condition:
<?php if ( $localPhone == "Manchester") {
and see what happens.
I’ve tried with and without spaces, I’ll try the single condition, I’ll be in touch tomorrow no doubt! Thanks for your help so far ray. Night
Ha!
I had this thread up, walked away for twenty minutes, forgot to refresh, and just posted. Of course, in that time there were eight additional posts. Oops!
Right I’ve tried the single quote on it now. still no luck, my face is currently like my avatar! glum!
Any further ideas? I can’t see how something as simple as doing a check on existing data in the loop should be some troublesome.