DSystem Posted February 22, 2018 Posted February 22, 2018 I'm doing block on ipPages and I need it to be visalisado only in downloads of a certain category. Block Script: {{if \IPS\Request::i()->controller == 'view' && request.app == 'downloads' && request.module == 'downloads' && \IPS\Request::i()->category == 22}} <BR> test {{endif}} does not work because \IPS\Request::i()->category does not return any value. What would be the right \IPS\Request?
Daniel F Posted February 22, 2018 Posted February 22, 2018 37 minutes ago, DSystem said: I'm doing block on ipPages and I need it to be visalisado only in downloads of a certain category. Block Script: {{if \IPS\Request::i()->controller == 'view' && request.app == 'downloads' && request.module == 'downloads' && \IPS\Request::i()->category == 22}} <BR> test {{endif}} does not work because \IPS\Request::i()->category does not return any value. What would be the right \IPS\Request? I assume you copy & pasted this? THere's no reason to use \IPS\Requestion::I() and request. at the same time! request is just a shortcut for \IPS\Request::I(); A reminder for the other shortcuts: member settings output theme cookie /** * Expand shortcuts * * @param string $content Content with shortcuts * @return string Content with shortcuts expanded */ public static function expandShortcuts( $content ) { /* Parse shortcuts */ foreach ( array( 'request' => 'i', 'member' => 'loggedIn', 'settings' => 'i', 'output' => 'i' ) as $class => $function ) { $content = preg_replace( '/(^|[^\$\\\])' . $class . "\.(\S+?)/", '$1\IPS\\' . mb_ucfirst( $class ) . '::' . $function . '()->$2', $content ); } foreach( array( 'theme' => '\IPS\\Theme::i()->settings', 'cookie' => '\IPS\\Request::i()->cookie' ) as $shortcut => $array ) { $content = preg_replace( '/(^|[^\$\\\])' . $shortcut .'\.(.([a-zA-Z0-9_]+))/', '$1'. $array . '[\'$2\']', $content ); } return $content; } I hope this helps to avoid some confusion.
DSystem Posted February 22, 2018 Author Posted February 22, 2018 41 minutes ago, Adriano Faria said: \ IPS \ Request :: i () -> id This returns the download ID. I need the ID of the download category
Adriano Faria Posted February 22, 2018 Posted February 22, 2018 You never said you’re on file view, did you? You have to load the file and get the $file->cat. Request ID in file view is the file ID. There’s no data of the category.
DSystem Posted February 22, 2018 Author Posted February 22, 2018 35 minutes ago, Adriano Faria said: You have to load the file and get the $file->cat. Request ID in file view is the file ID. There’s no data of the category. Thank you very much. It worked perfectly....
Recommended Posts
Archived
This topic is now archived and is closed to further replies.