Jump to content

How to replace FontAwesome Icons


Recommended Posts

Hello guys,

I have developed a new WHMCS theme and want to use different icons than FontAwesome for primarynavbar, secondarynavbar and homepanel.

I have an error telling me that only FontAwesome works on WHMCS, can you help me change the editor?

Thank you very much.

Link to comment
Share on other sites

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
if (!is_null($primarySidebar->getChild('Ticket Information'))) {
$primarySidebar->getChild("Ticket Information")
->setIcon("icon-info");
}
});

add_hook('ClientAreaHomepagePanels', 1, function(MenuItem $homePagePanels)
{
if (!is_null($homePagePanels->getChild('Active Products/Services'))) {
$homePagePanels->getChild("Active Products/Services")
->setIcon("icon-layers");
}
});

Link to comment
Share on other sites

21 hours ago, Romain Faure said:

I have an error telling me that only FontAwesome works on WHMCS, can you help me change the editor?

it's FontAwesome and/or Glyphicons, and they need to be one or the other.

I suppose you could get around the check by using a fontawesome icon in the hook...

->setIcon("fa-layers");

and then modifying that value (the fa part) in the appropriate template - take a look in the /six/includes/ folder and view the code in navbar.tpl, sidebar.tpl etc to see how the icons are displayed and then adjust to how you need it to display your icons.

Link to comment
Share on other sites

Hi Brian,

I don't understand the connection with the hook modification, since it's not possible to edit the code manually:

<div menuItemName="{$item->getName()}" class="panel panel-default panel-accent-{$item->getExtra('color')}{if $item->getClass()} {$item->getClass()}{/if}"{if $item->
getAttribute('id')} id="{$item->
getAttribute('id')}"{/if}>
<div class="panel-heading">
	<h3 class="panel-title">
		{if $item->
		hasIcon()}
-->		<i class="{$item->getIcon()}"></i>       <-- (ex: <i class="icon-layers"></i> )
		 {/if}{$item->
		getLabel()}{if $item->
		hasBadge()} 
		<span class="badge">
		{$item->
		getBadge()}
		</span>
		{/if}
	</h3>
</div>

 

Results :

image.thumb.png.7341c50b3385e6bf60918f9cbd04b6d0.png

 

Thank you.

Link to comment
Share on other sites

Hi,

21 hours ago, Romain Faure said:

I don't understand the connection with the hook modification,

think of the navbar, sidebar or panel as an array - the hook can modify that array; the template outputs that array.

21 hours ago, Romain Faure said:

since it's not possible to edit the code manually

oh there are ways to edit the code. :!:

so let's say we have a homepage panel...

EozZkp6.png

then we'll use a hook to modify the icon...

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaHomepagePanels', 1, function(MenuItem $homePagePanels)
{
	if (!is_null($homePagePanels->getChild('Domains Expiring Soon'))) {
		$homePagePanels->getChild("Domains Expiring Soon")
			->setIcon("fa-brian");
	}
}); 

but that icon doesn't exist, therefore there's nothing to show...

RQelJNa.png

...so next step is to modify the clientareahome.tpl template and change...

{if $item->hasIcon()}<i class="{$item->getIcon()}"></i>&nbsp;{/if}

to...

{if $item->hasIcon()}<i class="{$item->getIcon()|replace:'brian':'clock'}"></i> {/if}

.... and now we've changed the icon! :smile:

nZW9Ut5.png

looking at your code, which I hadn't seen previously (I didn't know if you were using classes or images), you should be able to use the following in the hook...

->setIcon("fa-layers");

and then in the template...

<i class="{$item->getIcon()|replace:'fa-':'icon-'}"></i>

 

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