0

I need to change the logo if the page is used in my custom modules. There are 2 Logos - Logo 1 and Logo 2. My Module

  1. test/login
  2. test/list

If the above modules come I need to show the Logo 2

0

I am just giving some hint like how can you get the url or action name, i mean the url from your address bar like this -

// by default: URL_TYPE_LINK is returned
        echo $this->_storeManager->getStore()->getBaseUrl() . '<br />';        
        
        echo $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB) . '<br />';
        echo $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK) . '<br />';
        echo $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . '<br />';
        echo $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_STATIC) . '<br />';
        

Reference - https://www.mageplaza.com/devdocs/how-get-base-url-current-url-magento-2.html
Once you get the url you can use

if($url=="test/login"){echo "<img src='path_of_logo_image2'>";}
if($url=="test/list"){echo "<img src='path_of_logo_image2'>";}

Edit For plain PHP getting url is

$url="";
$url.= $_SERVER['HTTP_HOST'];   
    
    // Append the requested resource location to the URL   
    $url.= $_SERVER['REQUEST_URI'];    
      
    echo $url;  
2
  • Thanks for your reply, but if the module contains more that url i need to do it for all the sections and i need to add this condition for all the url's staticly, can get any dynamic solution that means if the module's url's are called then need to show this logo need to hide this section like that, can we do it with default.xml – Sabareesh May 4 at 4:50
  • 1
    I edited my code(test/login and test/list) only two places you need to add if condtion in the header file you can extract the url and check in the header.php only .. the you can hide the section using if condition .. keep the whole section in the $variable_any (any php variable), that can hold the whole section , then replace it or echo when ever required. Please try deeply, just go more inside the code and flow. – Vibhore Jain May 4 at 5:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.