Jump to content

Pages and Blocks


bradl

Recommended Posts

Posted

I think this is (or was?) a longs-standing issue with blocks on pages but wondering if there is a fix that maybe I've missed?  I'm using a database for an iinventory. The db does not use categories. 

The page associated with the database uses a listing template to show all club-owned items with its current status (checked in to storage, in use by a member, etc.).

I have a database feed block that shows a pared-down "quicklist" of all items that I'd like to use as a sidebar on the detail ("display") records for each item. So a person can jump directly from one item record to a different item record without having to go back to the main page.

This guide  on dynamic blocks seemed promising, but I can't figure out how to construct an If statement to not show on the listing page since it has the same base URL on which the display records are based.

{{if strpos( \IPS\Request::i()->path, '/inventory/' ) == FALSE}}

I'd like to ...

Show feed block:
http://www.myite.org/inventory/pandoras-box-r1/

Hide feed block on main database "summary" page:
http://www.mysite.org/inventory/

Tips or pointers appreciated. 

  • 3 weeks later...
Posted

One bump before I give up. Possible or not to show a block on display template but not on listing template for a database on a Pages page?

Posted

I'm not familiar with Pages, but try to print {\IPS\Dispatcher::i()->controller}. I think it'll be different depending on whether it's a listing or display template. Then just use that. 

Alternatively, you could try with preg_match, but you should be able to use better logic than that, because checking the URL path for this is really not what you should be doing. But if you just need a solution right now and the above doesn't give you any solution. 

It would be something like: 

if( preg_match( \IPS\Request::i()->path, '#\/inventory\/.+#', $matches ) ) {
	# show on display template
}

 

Archived

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...