Jump to content

Change URL for Home and Logo on WHMCS 7.2.1


Recommended Posts

the logo link is in header.tpl...

 

        {if $assetLogoPath}
           <a href="{$WEB_ROOT}/index.php" class="logo"><img src="{$assetLogoPath}" alt="{$companyname}"></a>
       {else}
           <a href="{$WEB_ROOT}/index.php" class="logo logo-text">{$companyname}</a>
       {/if}

and for the menu, add a .php file to /includes/hooks and add...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
   if (!is_null($primaryNavbar->getChild('Home'))) {
           $primaryNavbar->getChild('Home')
                       ->setURI('http://www.google.com');
   }
});

 

https://forum.whmcs.com/showthread.php?126234-How-do-you-change-the-breadcrumbs-or-sidebar-code&p=505822#post505822

Link to comment
Share on other sites

Thank you, for the Home menu worked fine, but for the Logo, I don't know where to add the URL I want to redirect to.

 

{if $assetLogoPath}

<a href="{$WEB_ROOT}/index.php" class="logo"><img src="{$assetLogoPath}" alt="{$companyname}"></a>

{else}

<a href="{$WEB_ROOT}/index.php" class="logo logo-text">{$companyname}</a>

{/if}

Link to comment
Share on other sites

  • 2 years later...
On 27/11/2019 at 03:05, Thomasmcdaniel9 said:

Hey guys I hope this is still active. Im not  very good at this because it did not work for me I use cpanel file manager located the whmcs file added code to the template index file nothing changed. Please help 

this old solution was to change the link used by your logo on the WHMCS page - from reading your other thread, I think your situation relates to changing the link on the home menu button, which would require a different solution.

Link to comment
Share on other sites

  • 11 months later...
8 minutes ago, brian! said:

<?php

# Change Logo URL Hook
# Written by brian!

function change_logo_url_hook($vars) {
	
	return "<script>
$(function(){
   $('a.logo').attr('href','https://www.google.com');
});
</script>";
}
add_hook("ClientAreaFooterOutput", 1, "change_logo_url_hook");

 

Thanks a lot! How to open the link in new tab?

Link to comment
Share on other sites

21 hours ago, Md Rasel Khan said:

setUri link should be open in new tab. Please help me, thanks!

setURI just specified the URL to use, if you want more, you would need to use setAttribute....

your quoted code is about navbars, but the attachment is sidebars - i'll choose one as an example, but it's the same code for either...

    // Sidebar->Support->Blog/News
    if (!is_null($secondarySidebar->getChild('Support'))) {
        $secondarySidebar->getChild('Support')
        ->getChild('Announcements')
        ->setLabel("Blog/News")
        ->setUri('https://omnisoftit.com/blog')
        ->setAttribute('target','_blank')
        ->setOrder(0);
    }
4 hours ago, VirtualWorldGlobal said:

can a hook perform this action ?

<?php

# Show Logo On Login Page Hook
# Written by brian!

function show_logo_on_login_page_hook($vars) {
	
	if ($vars['showingLoginPage']) {
		$imageurl = 'https://upload.wikimedia.org/wikipedia/en/c/ce/SVG-logo.svg';
		$output .= '<script type="text/javascript">
$(document).ready(function(){
	 $("<img src=\"'.$imageurl.'\" >").insertBefore(".header-lined");
});
</script>';
		return $output;
	}
}
add_hook("ClientAreaHeaderOutput", 1, "show_logo_on_login_page_hook");

6KBHuyC.png

if the image isn't the correct size, then you will have set its dimension in the code - either as a CSS class which you had to the img tag, or specific width/height dimensions.

Link to comment
Share on other sites

11 hours ago, brian! said:

setURI just specified the URL to use, if you want more, you would need to use setAttribute....

your quoted code is about navbars, but the attachment is sidebars - i'll choose one as an example, but it's the same code for either...


    // Sidebar->Support->Blog/News
    if (!is_null($secondarySidebar->getChild('Support'))) {
        $secondarySidebar->getChild('Support')
        ->getChild('Announcements')
        ->setLabel("Blog/News")
        ->setUri('https://omnisoftit.com/blog')
        ->setAttribute('target','_blank')
        ->setOrder(0);
    }

 

Thanks! Is there any way to add this line on the head.tpl file by hook? Not by directly editing the head.tpl file.Screenshot_1.thumb.png.e69e527cfb236d303adc3ee2976f3b91.png

Link to comment
Share on other sites

  

On 6/6/2020 at 5:45 PM, brian! said:

ideally, you wouldn't edit any template for this - it's really a task for a hook (otherwise you'll be editing the template after every update).


<?
add_hook('ClientAreaHeadOutput', 1, function($vars) {
	return '<link rel="icon" href="https://www.youstable.com/favicon.ico" />';
});

@brian! Thanks a lot!  Is there any way to add this custom CSS by hook?

image.png.d531031f5600b4b8c2b601ad8727614a.png

 

Link to comment
Share on other sites

38 minutes ago, Md Rasel Khan said:

  

@brian! Thanks a lot!  Is there any way to add this custom CSS by hook?

image.png.d531031f5600b4b8c2b601ad8727614a.png

 

@brian! I have added the custom CSS using your way. Do you think it is a good practice? Or do you have better way? And in the future If I update the WHMCS this mystyle.css will be removed or not?

Screenshot_4.png.a071f2b6160bb80fea77e5be20d49414.png

Thanks!

Link to comment
Share on other sites

Thanks @brian!

 

On 11/13/2020 at 9:36 PM, brian! said:

<?php # Show Logo On Login Page Hook # Written by brian! function show_logo_on_login_page_hook($vars) { if ($vars['showingLoginPage']) { $imageurl = 'https://upload.wikimedia.org/wikipedia/en/c/ce/SVG-logo.svg'; $output .= '<script type="text/javascript"> $(document).ready(function(){ $("<img src=\"'.$imageurl.'\" >").insertBefore(".header-lined"); }); </script>'; return $output; } } add_hook("ClientAreaHeaderOutput", 1, "show_logo_on_login_page_hook");

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated