Jump to content

Pages / looping


Lachuks

Recommended Posts

Hey there!

Im kinda new in ips arena and dont really understand how things works here. Want to make custom page to display users from specific groups but dont know how. How SELECT and looping works? Cuz as far as i understood </php> doesnt work there.

Link to comment
Share on other sites

4 hours ago, Triqqy said:

You will need to use the Pages application to make a new page.

Seems you got me wrong. I have all needed for that but as far as I understand IPS has its own "working with members" and "working with databse" functions and I have no clue how to use them. I need an example of displaying cartain groups in a simple table so I can edit it for my needs

Link to comment
Share on other sites

Seems you got me wrong once again. I want to DISPLAY an group members in a table not to make page visiable to that group. I dont really understand how to explain it better. Here is quick look of what I want:

<table>
  <!-- looping thrue group ( id 4 ) members -->
  <tr>
    <td>{member name}</td>
    <td>{member age}</td>
    <td>{...}</td>
  </tr>
</table>

If you still dont get my idea maybe we can contact on skype or discord?

Link to comment
Share on other sites

  • Administrator

You don't need to write the table yourself when it's a default system block. If you're really adamant about creating your own, this should help:

https://invisioncommunity.com/4docs/advanced-usage/development/working-with-members-r179/

Link to comment
Share on other sites

As I said before I'm newbie and have no clue how to start. I know only how to load user by knowing his ID or email. There is no examples of how can I load multiple users from specific group and display them in a list

Link to comment
Share on other sites

  • Administrator

There's an entire database on the Invision community that will assist you in learning how to use the software. It's not complicated.

If you're a "newbie", then stick to using default blocks. We're not going to teach you a programming language in addition to the fundamentals of point-n-click for forum software.

https://invisioncommunity.com/4guides/getting-started/using-the-block-manager-r309/

Link to comment
Share on other sites

Blocks? That doesnt help me. I'm not asking to make whole code for me or teach me programming. I know few languages including web dev but never worked with IPS.

So far I found how to load an group {{$group = \IPS\Member\Group::load(4);}} but even with a deep search I can't find the way how can I get that groups members. 

Tried - {{$members = $group->members();}} (found somewhere on google) and then {{foreach $members as $member}} but then it shows a config error (Error: Call to undefined method IPS\Member\Group::members() (0))

Edited by Lachuks
Link to comment
Share on other sites

  • Administrator

You're asking to display a filterable list of members. That can be done with the default Members block.

If you're hellbent on creating your own table, start with the Members block and add your own extension.

Link to comment
Share on other sites

  • 2 weeks later...

Ok. Will try one more time. I want to make staff roster, something like this, where will be displayed few groups and its members ( see screenshot ).

Been searching all around internet but sadlty didn't find anything. Even talking code from staff page gives nothing. Currently using code like this but whenever staff changes I have to update roster manualy and it sux

Spoiler

<table>
  <tr>
    <th class="head" style="width:2%; text-align:center;"><i class="fas fa-globe-americas" aria-hidden="true"></i></th>
    <th class="head" style="width:3%; text-align:center;"><i class="fa fa-picture-o"></i></th>
    <th class="head" style="width:52%; text-align:left;">Username</th>
    <th class="head" style="width:30%; text-align:center;">Last visit</th>
    <th class="head" style="width:10%; text-align:center;">Reputation</th>
    <th class="head" style="width:3%; text-align:center;">PM</th>
  </tr>
  <tr>
    <td colspan="6" class="category" style="background-color: #e4e4e4;border-bottom: 1px solid;border-color: #f44336!important;text-align:center;">Leadership</td>
  </tr>
  <!-- start -->
  <tr>
    {{$id = 3;}}
    {{$member = \IPS\Member::load( $id );}}
    <td class="members" style="text-align:center;">1</td>
    <td class="members" style="text-align:left;"><a href="{$member->url()}"><img src='{$member->photo}' alt='' class='ipsUserPhoto ipsUserPhoto_tiny'></a></td>
    <td class="members usernames" style="text-align:left;font-size:15px;"><a style="font-weight: bold;" href="{$member->url()}">
      {{$name = $member->name;}}
      	    {{$group = $member->member_group_id;}}
			<strong>{expression="\IPS\Member\Group::load( $group )->formatName( $name )" raw="true"}</strong></a><span class="secondary_info">{$member->member_title}</span>
    </td>
    <td class="members" style="text-align:center;">
      			<span>
					{{if $member->isOnline() AND ( !$member->isOnlineAnonymously() OR ( $member->isOnlineAnonymously() AND \IPS\Member::loggedIn()->isAdmin() ) )}}
                    	<i class="fa fa-circle" data-ipsTooltip title='{{if $member->isOnlineAnonymously()}}{lang="online_now_anon" sprintf="$member->name"}{{elseif $member->isOnline()}}{lang="online_now" sprintf="$member->name"}{{endif}}'></i>
                    {{endif}}
                    {{if $member->last_activity}}{datetime="$member->last_activity"}{{else}}{lang="never"}{{endif}}
				</span>
    </td>
    <td class="members" style="font-weight: bold;color:#5f7a47 !important;text-align:center;"><i class="fa fa-plus-circle"></i> {number="$member->pp_reputation_points"}</td>
    <td class="members"><a href="https://my-site.com/index.php?/messenger/compose/&to={$id}"><i class="fa fa-envelope"></i></a></td>
  </tr>
  <!-- End -->
  <!-- start -->
  <tr>
    {{$id = 13;}}
    {{$member = \IPS\Member::load( $id );}}
    <td class="members" style="text-align:center;">1</td>
    <td class="members" style="text-align:left;"><a href="{$member->url()}"><img src='{$member->photo}' alt='' class='ipsUserPhoto ipsUserPhoto_tiny'></a></td>
    <td class="members usernames" style="text-align:left;font-size:15px;"><a style="font-weight: bold;" href="{$member->url()}">
      {{$name = $member->name;}}
      	    {{$group = $member->member_group_id;}}
			<strong>{expression="\IPS\Member\Group::load( $group )->formatName( $name )" raw="true"}</strong></a>{{if $member->member_title}}<span class="secondary_info">{$member->member_title}</span>{{endif}}
    </td>
    <td class="members" style="text-align:center;">
      			<span>
					{{if $member->isOnline() AND ( !$member->isOnlineAnonymously() OR ( $member->isOnlineAnonymously() AND \IPS\Member::loggedIn()->isAdmin() ) )}}
                    	<i class="fa fa-circle" data-ipsTooltip title='{{if $member->isOnlineAnonymously()}}{lang="online_now_anon" sprintf="$member->name"}{{elseif $member->isOnline()}}{lang="online_now" sprintf="$member->name"}{{endif}}'></i>
                    {{endif}}
                    {{if $member->last_activity}}{datetime="$member->last_activity"}{{else}}{lang="never"}{{endif}}
				</span>
    </td>
    <td class="members" style="font-weight: bold;color:#5f7a47 !important;text-align:center;"><i class="fa fa-plus-circle"></i> {number="$member->pp_reputation_points"}</td>
    <td class="members"><a href="https://my-site.com/index.php?/messenger/compose/&to={$id}"><i class="fa fa-envelope"></i></a></td>
  </tr>
  <!-- End -->
  <tr>
    <td colspan="6" class="category" style="background-color: #e4e4e4;border-bottom: 1px solid;border-color: #f44336!important;text-align:center;">Managers</td>
  </tr>
  <!-- start -->
  <tr>
    {{$id = 5;}}
    {{$member = \IPS\Member::load( $id );}}
    <td class="members" style="text-align:center;">1</td>
    <td class="members" style="text-align:left;"><a href="{$member->url()}"><img src='{$member->photo}' alt='' class='ipsUserPhoto ipsUserPhoto_tiny'></a></td>
    <td class="members usernames" style="text-align:left;font-size:15px;"><a style="font-weight: bold;" href="{$member->url()}">
      {{$name = $member->name;}}
      	    {{$group = $member->member_group_id;}}
			<strong>{expression="\IPS\Member\Group::load( $group )->formatName( $name )" raw="true"}</strong></a><span class="secondary_info">{$member->member_title}</span>
    </td>
    <td class="members" style="text-align:center;">
      			<span>
					{{if $member->isOnline() AND ( !$member->isOnlineAnonymously() OR ( $member->isOnlineAnonymously() AND \IPS\Member::loggedIn()->isAdmin() ) )}}
                    	<i class="fa fa-circle" data-ipsTooltip title='{{if $member->isOnlineAnonymously()}}{lang="online_now_anon" sprintf="$member->name"}{{elseif $member->isOnline()}}{lang="online_now" sprintf="$member->name"}{{endif}}'></i>
                    {{endif}}
                    {{if $member->last_activity}}{datetime="$member->last_activity"}{{else}}{lang="never"}{{endif}}
				</span>
    </td>
    <td class="members" style="font-weight: bold;color:#5f7a47 !important;text-align:center;"><i class="fa fa-plus-circle"></i> {number="$member->pp_reputation_points"}</td>
    <td class="members"><a href="https://my-site.com/index.php?/messenger/compose/&to={$id}"><i class="fa fa-envelope"></i></a></td>
  </tr>
  <!-- End -->
  <tr>
    <td colspan="6" class="category" style="background-color: #e4e4e4;border-bottom: 1px solid;border-color: #f44336!important;text-align:center;">Clan Members</td>
  </tr>
  <!-- start -->
  <tr>
    {{$id = 110;}}
    {{$member = \IPS\Member::load( $id );}}
    <td class="members" style="text-align:center;">1</td>
    <td class="members" style="text-align:left;"><a href="{$member->url()}"><img src='{$member->photo}' alt='' class='ipsUserPhoto ipsUserPhoto_tiny'></a></td>
    <td class="members usernames" style="text-align:left;font-size:15px;"><a style="font-weight: bold;" href="{$member->url()}">
      {{$name = $member->name;}}
      	    {{$group = $member->member_group_id;}}
			<strong>{expression="\IPS\Member\Group::load( $group )->formatName( $name )" raw="true"}</strong></a>{{if $member->member_title}}<span class="secondary_info">{$member->member_title}</span>{{endif}}
    </td>
    <td class="members" style="text-align:center;">
      			<span>
					{{if $member->isOnline() AND ( !$member->isOnlineAnonymously() OR ( $member->isOnlineAnonymously() AND \IPS\Member::loggedIn()->isAdmin() ) )}}
                    	<i class="fa fa-circle" data-ipsTooltip title='{{if $member->isOnlineAnonymously()}}{lang="online_now_anon" sprintf="$member->name"}{{elseif $member->isOnline()}}{lang="online_now" sprintf="$member->name"}{{endif}}'></i>
                    {{endif}}
                    {{if $member->last_activity}}{datetime="$member->last_activity"}{{else}}{lang="never"}{{endif}}
				</span>
    </td>
    <td class="members" style="font-weight: bold;color:#5f7a47 !important;text-align:center;"><i class="fa fa-plus-circle"></i> {number="$member->pp_reputation_points"}</td>
    <td class="members"><a href="https://m.com/index.php?/messenger/compose/&to={$id}"><i class="fa fa-envelope"></i></a></td>
  </tr>
  <!-- End -->
  </table>

 

 

Link to comment
Share on other sites

2 hours ago, Lachuks said:

Ok. Will try one more time. I want to make staff roster, something like this, where will be displayed few groups and its members ( see screenshot ).

Been searching all around internet but sadlty didn't find anything. Even talking code from staff page gives nothing. Currently using code like this but whenever staff changes I have to update roster manualy and it sux

  Reveal hidden contents


<table>
  <tr>
    <th class="head" style="width:2%; text-align:center;"><i class="fas fa-globe-americas" aria-hidden="true"></i></th>
    <th class="head" style="width:3%; text-align:center;"><i class="fa fa-picture-o"></i></th>
    <th class="head" style="width:52%; text-align:left;">Username</th>
    <th class="head" style="width:30%; text-align:center;">Last visit</th>
    <th class="head" style="width:10%; text-align:center;">Reputation</th>
    <th class="head" style="width:3%; text-align:center;">PM</th>
  </tr>
  <tr>
    <td colspan="6" class="category" style="background-color: #e4e4e4;border-bottom: 1px solid;border-color: #f44336!important;text-align:center;">Leadership</td>
  </tr>
  <!-- start -->
  <tr>
    {{$id = 3;}}
    {{$member = \IPS\Member::load( $id );}}
    <td class="members" style="text-align:center;">1</td>
    <td class="members" style="text-align:left;"><a href="{$member->url()}"><img src='{$member->photo}' alt='' class='ipsUserPhoto ipsUserPhoto_tiny'></a></td>
    <td class="members usernames" style="text-align:left;font-size:15px;"><a style="font-weight: bold;" href="{$member->url()}">
      {{$name = $member->name;}}
      	    {{$group = $member->member_group_id;}}
			<strong>{expression="\IPS\Member\Group::load( $group )->formatName( $name )" raw="true"}</strong></a><span class="secondary_info">{$member->member_title}</span>
    </td>
    <td class="members" style="text-align:center;">
      			<span>
					{{if $member->isOnline() AND ( !$member->isOnlineAnonymously() OR ( $member->isOnlineAnonymously() AND \IPS\Member::loggedIn()->isAdmin() ) )}}
                    	<i class="fa fa-circle" data-ipsTooltip title='{{if $member->isOnlineAnonymously()}}{lang="online_now_anon" sprintf="$member->name"}{{elseif $member->isOnline()}}{lang="online_now" sprintf="$member->name"}{{endif}}'></i>
                    {{endif}}
                    {{if $member->last_activity}}{datetime="$member->last_activity"}{{else}}{lang="never"}{{endif}}
				</span>
    </td>
    <td class="members" style="font-weight: bold;color:#5f7a47 !important;text-align:center;"><i class="fa fa-plus-circle"></i> {number="$member->pp_reputation_points"}</td>
    <td class="members"><a href="https://my-site.com/index.php?/messenger/compose/&to={$id}"><i class="fa fa-envelope"></i></a></td>
  </tr>
  <!-- End -->
  <!-- start -->
  <tr>
    {{$id = 13;}}
    {{$member = \IPS\Member::load( $id );}}
    <td class="members" style="text-align:center;">1</td>
    <td class="members" style="text-align:left;"><a href="{$member->url()}"><img src='{$member->photo}' alt='' class='ipsUserPhoto ipsUserPhoto_tiny'></a></td>
    <td class="members usernames" style="text-align:left;font-size:15px;"><a style="font-weight: bold;" href="{$member->url()}">
      {{$name = $member->name;}}
      	    {{$group = $member->member_group_id;}}
			<strong>{expression="\IPS\Member\Group::load( $group )->formatName( $name )" raw="true"}</strong></a>{{if $member->member_title}}<span class="secondary_info">{$member->member_title}</span>{{endif}}
    </td>
    <td class="members" style="text-align:center;">
      			<span>
					{{if $member->isOnline() AND ( !$member->isOnlineAnonymously() OR ( $member->isOnlineAnonymously() AND \IPS\Member::loggedIn()->isAdmin() ) )}}
                    	<i class="fa fa-circle" data-ipsTooltip title='{{if $member->isOnlineAnonymously()}}{lang="online_now_anon" sprintf="$member->name"}{{elseif $member->isOnline()}}{lang="online_now" sprintf="$member->name"}{{endif}}'></i>
                    {{endif}}
                    {{if $member->last_activity}}{datetime="$member->last_activity"}{{else}}{lang="never"}{{endif}}
				</span>
    </td>
    <td class="members" style="font-weight: bold;color:#5f7a47 !important;text-align:center;"><i class="fa fa-plus-circle"></i> {number="$member->pp_reputation_points"}</td>
    <td class="members"><a href="https://my-site.com/index.php?/messenger/compose/&to={$id}"><i class="fa fa-envelope"></i></a></td>
  </tr>
  <!-- End -->
  <tr>
    <td colspan="6" class="category" style="background-color: #e4e4e4;border-bottom: 1px solid;border-color: #f44336!important;text-align:center;">Managers</td>
  </tr>
  <!-- start -->
  <tr>
    {{$id = 5;}}
    {{$member = \IPS\Member::load( $id );}}
    <td class="members" style="text-align:center;">1</td>
    <td class="members" style="text-align:left;"><a href="{$member->url()}"><img src='{$member->photo}' alt='' class='ipsUserPhoto ipsUserPhoto_tiny'></a></td>
    <td class="members usernames" style="text-align:left;font-size:15px;"><a style="font-weight: bold;" href="{$member->url()}">
      {{$name = $member->name;}}
      	    {{$group = $member->member_group_id;}}
			<strong>{expression="\IPS\Member\Group::load( $group )->formatName( $name )" raw="true"}</strong></a><span class="secondary_info">{$member->member_title}</span>
    </td>
    <td class="members" style="text-align:center;">
      			<span>
					{{if $member->isOnline() AND ( !$member->isOnlineAnonymously() OR ( $member->isOnlineAnonymously() AND \IPS\Member::loggedIn()->isAdmin() ) )}}
                    	<i class="fa fa-circle" data-ipsTooltip title='{{if $member->isOnlineAnonymously()}}{lang="online_now_anon" sprintf="$member->name"}{{elseif $member->isOnline()}}{lang="online_now" sprintf="$member->name"}{{endif}}'></i>
                    {{endif}}
                    {{if $member->last_activity}}{datetime="$member->last_activity"}{{else}}{lang="never"}{{endif}}
				</span>
    </td>
    <td class="members" style="font-weight: bold;color:#5f7a47 !important;text-align:center;"><i class="fa fa-plus-circle"></i> {number="$member->pp_reputation_points"}</td>
    <td class="members"><a href="https://my-site.com/index.php?/messenger/compose/&to={$id}"><i class="fa fa-envelope"></i></a></td>
  </tr>
  <!-- End -->
  <tr>
    <td colspan="6" class="category" style="background-color: #e4e4e4;border-bottom: 1px solid;border-color: #f44336!important;text-align:center;">Clan Members</td>
  </tr>
  <!-- start -->
  <tr>
    {{$id = 110;}}
    {{$member = \IPS\Member::load( $id );}}
    <td class="members" style="text-align:center;">1</td>
    <td class="members" style="text-align:left;"><a href="{$member->url()}"><img src='{$member->photo}' alt='' class='ipsUserPhoto ipsUserPhoto_tiny'></a></td>
    <td class="members usernames" style="text-align:left;font-size:15px;"><a style="font-weight: bold;" href="{$member->url()}">
      {{$name = $member->name;}}
      	    {{$group = $member->member_group_id;}}
			<strong>{expression="\IPS\Member\Group::load( $group )->formatName( $name )" raw="true"}</strong></a>{{if $member->member_title}}<span class="secondary_info">{$member->member_title}</span>{{endif}}
    </td>
    <td class="members" style="text-align:center;">
      			<span>
					{{if $member->isOnline() AND ( !$member->isOnlineAnonymously() OR ( $member->isOnlineAnonymously() AND \IPS\Member::loggedIn()->isAdmin() ) )}}
                    	<i class="fa fa-circle" data-ipsTooltip title='{{if $member->isOnlineAnonymously()}}{lang="online_now_anon" sprintf="$member->name"}{{elseif $member->isOnline()}}{lang="online_now" sprintf="$member->name"}{{endif}}'></i>
                    {{endif}}
                    {{if $member->last_activity}}{datetime="$member->last_activity"}{{else}}{lang="never"}{{endif}}
				</span>
    </td>
    <td class="members" style="font-weight: bold;color:#5f7a47 !important;text-align:center;"><i class="fa fa-plus-circle"></i> {number="$member->pp_reputation_points"}</td>
    <td class="members"><a href="https://m.com/index.php?/messenger/compose/&to={$id}"><i class="fa fa-envelope"></i></a></td>
  </tr>
  <!-- End -->
  </table>

 

 

Aside from the fact that your code is very cluttered, you are almost there, you just have to use a foreach-loop.

{{foreach [expression]}}
	...
{{endforeach}}

 

Please no more private messages, mentions or anything like that. I don't offer any support at the moment.

Link to comment
Share on other sites

38 minutes ago, Oni said:

Aside from the fact that your code is very cluttered, you are almost there, you just have to use a foreach-loop.


{{foreach [expression]}}
	...
{{endforeach}}

 

What expression and how should I use this? Im new in all this so supportive hand would be appreciated.

<table>
{{$group = {expression="\IPS\Member\Group::load( 4 )"};}}
{{$members = $group->members();}}
	<tr>
      <td></td>
  	</tr>
{{foreach $members as $member}}
    <tr>
      <td></td>
    </tr>
{{endforeach}}
</table>

Thats what I tried but it doesnt work at all. Shows ERROR: EX0.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...