Jump to content
View in the app

A better way to browse. Learn more.

Invision Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Odd issue with using a function in a specific template

Featured Replies

Posted

I'm trying to edit some templates using hooks, so I can change how the name of a member gets displayed, if he is in a certain group, so I'm using in a fair amount of templates, successfully, something like this:

{{if $row->inGroup( $group = \IPS\app\Whatever::getGroup() }}
	Whatever
{{else}}
	Actual primary group
{{endif}}

However, there is this specific template, with which I've been at it for hours now, and can't have it working:

\applications\core\dev\html\front\widgets\activeUsers.phtml

div.ipsWidget_inner.ipsPad > ul.ipsList_inline.ipsList_csv.ipsList_noSpacing.ipsType_normal

as soon as I use something to "search" (inGroup(), in_array(), search_in_array(), etc) it borks that page and it seems to get in a loop (error 500/memory issue)

I have absolutely no idea how to go around this...

Thanks in advance!

EDIT: I feel like this is an escaping issue, I already had to change some of the quotes in the URL that exists there, because it was having the same effect

Edited by Herlander Carvalho

You should provide the complete code. 

 

div.ipsWidget_inner.ipsPad > ul.ipsList_inline.ipsList_csv.ipsList_noSpacing.ipsType_normal

$row inside foreach loop

In your case $row outside

		<ul class='ipsList_inline ipsList_csv ipsList_noSpacing ipsType_normal'>
			{{if \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members' ) ) }}
				{{foreach $members as $row}}
					<li>

 

 

However, there is this specific template, with which I've been at it for hours now, and can't have it working:

In that template $row is an array not object

  • Author
 

You should provide the complete code. 

You are absolutely right, but I wasn't sure what to post since it's an edit of a default template, and I was really fed up with the amount of time I spent trying to fix this issue

 

 

in that template $row is an array not object

As soon as I read this I knew that was the problem, and fixed it, duh! Thank you you so very much for your help!!!

 

but I still have the URL not being properly parsed though. This is just an exact copy of what the template has:

<a href="{url="app=core&module=members&controller=profile&id={$row['member_id']}" seoTemplate="profile" seoTitle="$row['seo_name']"}" data-ipshover="" data-ipshover-target="">

If I use it exactly like that, server hangs... when I try different solutions to avoid the quotes hell, I may get something "closer " to the expected result but $row['member_id'] is always returning value 1? puzzled...

 

EDIT:

Here's the full edit code for reference, its using replacing btw:

<ul class="ipsList_inline ipsList_csv ipsList_noSpacing ipsType_normal">
	{{if \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members' ) ) }}
		{{foreach $members as $row}}
			<li>
				<a href="{url="app=core&module=members&controller=profile&id={$row['member_id']}" seoTemplate="profile" seoTitle="$row['seo_name']"}" data-ipshover="" data-ipshover-target="">
					{{if \IPS\Member::load( $row['member_id'] )->inGroup( $patronsGroup = \IPS\patreon\Login::getPatronsGroup() ) }}
						{expression="\IPS\Member\Group::load( $patronsGroup )->formatName( $row['member_name'] )" raw="true"}
					{{else}}
						{expression="\IPS\Member\Group::load( $row['member_group'] )->formatName( $row['member_name'] )" raw="true"}
					{{endif}}
				</a>
			</li>
		{{endforeach}}
		{{else}}
			{{foreach $members as $row}}
				<li>
					{{if $row['in_editor']}}
						<i class="fa fa-circle-o-notch fa-spin" data-ipstooltip="" data-ipstooltip-label="{lang="block_user_in_editor"}"> </i>
					{{endif}}
					{expression="\IPS\Member\Group::load( $row['member_group'] )->formatName( $row['member_name'] )" raw="true"}
				</li>
			{{endforeach}}
		{{endelse}}
	{{endif}}
</ul>

 

Edited by Herlander Carvalho

You load member so you can use it

{{$member = \IPS\Member::load( $row['member_id'] );}}
<a href="{$member->url()}" data-ipshover="" data-ipshover-target="">

instead of

				<a href="{url="app=core&module=members&controller=profile&id={$row['member_id']}" seoTemplate="profile" seoTitle="$row['seo_name']"}" data-ipshover="" data-ipshover-target="">

 

  • Author

Thank you again for your help @newbie LAC

The hover thingy wasn't working but I managed to edit your suggestion to do so:

<a href="{$member->url()}" data-ipshover="" data-ipshover-target="{$member->url()->setQueryString( 'do', 'hovercard' )}">

 

Archived

This topic is now archived and is closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.