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.

(Advanced) Building dynamic blocks based on the page being viewed

For more advanced sites built with Pages, you may want to change the output of a custom HTML or PHP block depending on which page the user is viewing. For example, if you have a custom menu, you may want to highlight the active item.

We can implement this in Pages by checking the underlying page URL parameters. Although you access a page with a friendly URL (FURL) like http://<yourcommunity>/section/page, behind the scenes this is mapped to a raw URL, such as http://<yourcommunity>/index.php?app=cms&module=pages&controller=page&path=/section/page. Notice the path parameter allows us to identify which page we're accessing. When we access the \IPS\Request::i() object, we can compare against this parameter, like so:

{{if strpos( \IPS\Request::i()->path, 'section/page' ) !== FALSE}}
	<!-- We know the user is on /section/page -->
{{elseif strpos( \IPS\Request::i()->path, 'othersection/otherpage' ) !== FALSE}}
	<!-- We know the user is on /othersection/otherpage -->
{{endif}}

Note that for reliability, we're using PHP's strpos function to check for the presence of the page URL in the path parameter, rather than a simple comparison.

Example

Let's assume we've created a Manual HTML block, we're adding HTML to show a menu, and we want to highlight the correct item based on the page. Here's what our block contents might look like:

<ul class='ipsList_inline cMyMenu'>
  <li {{if strpos( \IPS\Request::i()->path, 'help/home' ) !== FALSE}}class='active'{{endif}}>
    <a href='/help/home'>Home</a>
  </li>
  <li {{if strpos( \IPS\Request::i()->path, 'help/faq' ) !== FALSE}}class='active'{{endif}}>
    <a href='/help/faq'>FAQ</a>
  </li>
  <li {{if strpos( \IPS\Request::i()->path, 'help/tutorials' ) !== FALSE}}class='active'{{endif}}>
    <a href='/help/tutorials'>Tutorials</a>
  </li>
</ul>
  

If we had many items to show, it would get tedious to list them all like this. We could instead do it as a loop:

// Using a PHP variable to store an array of pages => page names that we'll loop over
{{$myPages = array('help/home' => "Home", 'help/faq' => "FAQ", 'help/tutorials' => "Tutorials", 'help/qna/listing' => "Questions", 'help/qna/recent' => "Recent Questions", 'help/contact' => "Contact Us");}}

<ul class='ipsList_inline cMyMenu'>
	{{foreach $myPages as $url => $title}}
  		<li {{if strpos( \IPS\Request::i()->path, $url ) !== FALSE}}class='active'{{endif}}>
			<a href='{$url}'>{$title}</a>
	  	</li>
  	{{endforeach}}
</ul>

Now to add new items to our custom menu, we just have to add them to the array.

Account

Navigation

Search

Search

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.