Jump to content

Help with Request Data with Ipdownloads


DSystem

Recommended Posts

Posted

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?

Posted
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.

Posted
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....

Archived

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

  • Recently Browsing   0 members

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