Jump to content
  • [Beta 9.1] Changes for \IPS\Helpers\Menu\Link


     This is the current construct method of the file:

    	public function __construct( Url|string $url, string $languageString, string $css ='ipsMenu_item', array $dataAttributes = [], bool $opensDialog = FALSE, ?string $icon = NULL, string $id = NULL, string $identifier = '' )
    	{
    		$this->url = $url;
    		$this->title = $languageString;
    		$this->css = $css;
    		$this->dataAttributes = $dataAttributes;
    		$this->icon = $icon;
    
    		$this->menuItem = $identifier ?: $languageString;
    
    		if( !$id )
    		{
    			$id = 'menuLink_' . md5($languageString ) . '_' . $this->identifier;
    		}
    		$this->id = $id;
    		if( $opensDialog )
    		{
    			$this->opensDialog();
    		}
    
    		$this->addAttribute( 'data-menuItem', $languageString);
    	}

     

    Here's a list of issues:

    1. The $this->identifier variable is always empty when used to create a missing $id.
    2. The last line that adds the data-menuItem attribute should use $this->menuItem rather than $languageString.
    3. [Not really a bug] After the class values are set at the top you should use those rather than the function variables.

     

    Here's the updated code with all the changes if you want to copy/paste it. 😋

    	public function __construct( Url|string $url, string $languageString, string $css ='ipsMenu_item', array $dataAttributes = [], bool $opensDialog = FALSE, ?string $icon = NULL, string $id = NULL, string $identifier = '' )
    	{
    		$this->url = $url;
    		$this->title = $languageString;
    		$this->css = $css;
    		$this->dataAttributes = $dataAttributes;
    		$this->icon = $icon;
    		$this->identifier = $identifier;
    		
    		$this->menuItem = $this->identifier ?: $this->title;
    		
    		if( !$id )
    		{
    			$id = 'menuLink_' . md5($this->title ) . '_' . $this->identifier;
    		}
    		$this->id = $id;
    		
    		if( $opensDialog )
    		{
    			$this->opensDialog();
    		}
    		
    		$this->addAttribute( 'data-menuItem', $this->menuItem );
    	}

    User Feedback

    Recommended Comments

    teraßyte

    Posted

    This other bug report I made before is also related to the same file/class:


×
×
  • Create New...