Advertisement:

Author Topic: Very small db_query code to smcFunc  (Read 3729 times)

Offline shumilica

  • Jr. Member
  • **
  • Posts: 218
  • Gender: Male
  • SMF all the way!
    • Psiholog Body Mind Spirit
Re: Very small db_query code to smcFunc
« Reply #20 on: December 10, 2009, 02:31:00 AM »
So, in Load.php is this one:
Code: (Load.php) [Select]
$groups = $profile['additional_groups'];

// additional groups modification
if (!empty($groups))
{
$result = $smcFunc['db_query']('', '
SELECT group_name
FROM {db_prefix}membergroups
WHERE id_group IN ({array_string:groups})',
array(
'groups' => explode(', ', $groups),
)
);

while ($row = mysql_fetch_assoc($result))
$memberContext[$user]['additional_groups']['name'][] = $row['group_name'];
mysql_free_result($result);
}

And in display.template.php is now like this:

Code: [Select]
      if (!empty($message['member']['additional_groups']))
      echo implode('<br />', $message['member']['additional_groups']['name']), '<br />';

It's now working without the 2 ( i forgot about the $groups = $profile['additional_groups']; ), but is STILL showing only the first additional group...
Today, if you're not confused it means you're not thinking clear!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,782
    • StoryBB/StoryBB on GitHub
Re: Very small db_query code to smcFunc
« Reply #21 on: December 10, 2009, 02:31:54 AM »
And how many should there be (excluding primary group and post count group) ?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline shumilica

  • Jr. Member
  • **
  • Posts: 218
  • Gender: Male
  • SMF all the way!
    • Psiholog Body Mind Spirit
Re: Very small db_query code to smcFunc
« Reply #22 on: December 10, 2009, 02:34:49 AM »
all the additional groups they are in (excluding the primary group, and the post count group, wich are shown perfectly). If they have 2-3-4-5 additional groups that should be shown. In this way it only shows the first additional group found (it seems to be in alfabetical order :-? don't know for sure)
Today, if you're not confused it means you're not thinking clear!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,782
    • StoryBB/StoryBB on GitHub
Re: Very small db_query code to smcFunc
« Reply #23 on: December 10, 2009, 02:37:21 AM »
And any errors in your error log?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline shumilica

  • Jr. Member
  • **
  • Posts: 218
  • Gender: Male
  • SMF all the way!
    • Psiholog Body Mind Spirit
Re: Very small db_query code to smcFunc
« Reply #24 on: December 10, 2009, 02:41:23 AM »
none... :o
Today, if you're not confused it means you're not thinking clear!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,782
    • StoryBB/StoryBB on GitHub
Re: Very small db_query code to smcFunc
« Reply #25 on: December 10, 2009, 03:28:34 AM »
Please show me an example of a user's profile and a thread they posted in, so I can take a look.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline shumilica

  • Jr. Member
  • **
  • Posts: 218
  • Gender: Male
  • SMF all the way!
    • Psiholog Body Mind Spirit
Re: Very small db_query code to smcFunc
« Reply #26 on: December 10, 2009, 03:52:10 AM »
Ok, but my bord is not in english (plus the link is to a test forum):
http://fcrp.ro/forumdetest/index.php?topic=10072.msg112077#msg112077 (username Adeela is part of at least 3 additional groups: 'tip:universitar zi', 'anul ii', 'grupa 1', 'grupa 2' etc.) but in posts it only show the 'tip:universitar zi', and it shows it first because when i created the group i've puted some spaces in the beggining so that it will show up above the groups wich started with 'a' (i told you this to explain why i said earlier in the topic that it sorts alfabetical, and only the first alfabetical addtional group is shown).
Today, if you're not confused it means you're not thinking clear!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,782
    • StoryBB/StoryBB on GitHub
Re: Very small db_query code to smcFunc
« Reply #27 on: December 10, 2009, 03:54:43 AM »
So what primary group does that user have, then? (That's why I wanted to see profile too)
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline shumilica

  • Jr. Member
  • **
  • Posts: 218
  • Gender: Male
  • SMF all the way!
    • Psiholog Body Mind Spirit
Re: Very small db_query code to smcFunc
« Reply #28 on: December 10, 2009, 03:58:55 AM »
That example hadn't any primary membgroup, if you look again, i've put the username to a primary membergroup (Copil Inalt). Still no show (i checked with other examples).
Today, if you're not confused it means you're not thinking clear!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,782
    • StoryBB/StoryBB on GitHub
Re: Very small db_query code to smcFunc
« Reply #29 on: December 10, 2009, 04:01:33 AM »
It might help if you used the entire code segment I posted. mysql_fetch_assoc should not be used in 2.0 by mods.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline shumilica

  • Jr. Member
  • **
  • Posts: 218
  • Gender: Male
  • SMF all the way!
    • Psiholog Body Mind Spirit
Re: Very small db_query code to smcFunc
« Reply #30 on: December 10, 2009, 04:12:10 AM »
wow, i didn't even notice that you've changed that code too. I changed it now, but still, the same...
Today, if you're not confused it means you're not thinking clear!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,782
    • StoryBB/StoryBB on GitHub
Re: Very small db_query code to smcFunc
« Reply #31 on: December 10, 2009, 04:19:51 AM »
The only reason I think of is that the [] is missing in the declaration.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline shumilica

  • Jr. Member
  • **
  • Posts: 218
  • Gender: Male
  • SMF all the way!
    • Psiholog Body Mind Spirit
Re: Very small db_query code to smcFunc
« Reply #32 on: December 10, 2009, 04:24:25 AM »
And how/where should i put them? :-s
Today, if you're not confused it means you're not thinking clear!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,782
    • StoryBB/StoryBB on GitHub
Re: Very small db_query code to smcFunc
« Reply #33 on: December 10, 2009, 04:25:44 AM »
$memberContext[$user]['additional_groups']['name'][] = $row['group_name'];

They're there in that code excerpt.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline shumilica

  • Jr. Member
  • **
  • Posts: 218
  • Gender: Male
  • SMF all the way!
    • Psiholog Body Mind Spirit
Re: Very small db_query code to smcFunc
« Reply #34 on: December 10, 2009, 04:33:40 AM »
they are in my load.php too...
So, i think this solution just doesn't work for smf2... :(
Today, if you're not confused it means you're not thinking clear!

Offline shumilica

  • Jr. Member
  • **
  • Posts: 218
  • Gender: Male
  • SMF all the way!
    • Psiholog Body Mind Spirit
Re: Very small db_query code to smcFunc
« Reply #35 on: December 10, 2009, 04:44:24 AM »
Hmmm, if this second solution doesn't work, the first one, that prooved working in the profile.template, do you know how to make it work in the display.template too?

Code: [Select]
// Begin modification - Additional membergroups on profile
$x = 1;
// Loop through each additional group
foreach ($message['member']['additional_groups2'] as $additional_group)
{
// Add one to our counter
$x++;
// Output this membergroup
echo '
<li class="membergroup">', $additional_group, '</li>';
}
// End modification
Today, if you're not confused it means you're not thinking clear!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,782
    • StoryBB/StoryBB on GitHub
Re: Very small db_query code to smcFunc
« Reply #36 on: December 10, 2009, 06:34:54 AM »
Well, assuming Display.php loads it in to $message['member']['additional_groups'] as before...

Code: [Select]
// Begin modification - Additional membergroups on profile
$x = 1;
// Loop through each additional group
foreach ($message['member']['additional_groups'] as $additional_group)
{
// Add one to our counter
$x++;
// Output this membergroup
echo '
', $additional_group, '<br />';
}
// End modification
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.