Font Awesome Pro

I have a Font Awesome Pro subscription and would like to use that instead of the free version that’s included with PHPMaker. I can easily add the necessary script tag, but other than manually modifying layout.php, I don’t see a way to remove the FA style sheet for the free version. Loading both versions of FA would create unnecessary overhead and they would potentially conflict.

Therefore, I’d like to request an option in Advanced Settings to either disable the free version, so we can add our code manually, or allow us to enter custom code that would replace the code for the free version. Please allow us to replace the entire tag, not just the URL, because I want to use the SVG version of FA.

You may create your own Extension in order to change the code only in the layout.php file.Please read Extensions → Making Extensions from PHPMaker Help menu for more info.

I read the article in the help file. It seems it’s possible to completely replace the layout.php file using an extension, but I don’t see any way to replace just the link tag that loads the Font Awesome CSS. Replacing the entire file would be extreme overkill for such a simple modification. It would mean every time the layout.php is updated in the future, I’d have to manually update the extension.If extensions supported search/replace that would be much more useful.

You only need to replace the path of the Font Awesome stylesheet, e.g.<# args.code = args.code.replace(“fontawesome-free”, “fontawesome-pro”); #>

Thanks for the advice!I got the extension working, but each time I generate files, it disables the extension. There are no errors in the generated code and it performs the replacement, but when I return to the Extensions screen, the extension is disabled.In my layout.php extension file, I have:

<#
	let ext = GetExtensionObject("FontAwesomePro"); // Get extension object by extension name
    if (ext) {
        args.code = args.code.replace('<link rel="stylesheet" type="text/css" href="<?= $basePath ?>plugins/fontawesome-free/css/all.min.css">', '<script src="https://kit.fontawesome.com/' + ext.PROJ.KitID + '.js" crossorigin="anonymous"></script>');
    }
#>

This works, even if the extension is disabled, because it’s not checking whether it’s enabled. However, if I change the line to:

if (ext && ext.Enabled)

then it doesn’t work, because the extension always disables on generation. Why is this happening?

Please post your .xml file that belongs to your Extension for more discussion.

<?xml version="1.0" encoding="iso-8859-1" ?>
<ew-extension name="FontAwesomePro" version="17.0.0" type="Font Awesome Pro" author="Brad S Konia">
	<description>
		<![CDATA[
			Enables Font Awesome Pro
		]]>
	</description>
	<file>fontawesomepro.zip</file>
	<Project>
    	    <Attribute name="KitID" />
	</Project>
</ew-extension>

Try:

<#
    let ext = GetExtensionObject("FontAwesomePro"); // Get extension object by extension name
    if (ext.Enabled && ext.PROJ) {
        myKitID = ext.PROJ.KitID;
        args.code = args.code.replace('<link rel="stylesheet" type="text/css" href="<?= $basePath ?>plugins/fontawesome-free/css/all.min.css">', '<script src="https://kit.fontawesome.com/' + myKitID + '.js" crossorigin="anonymous"></script>');
    }
#>

In addition, for the attribute setting in .xml file, try this instead:

<Attribute name="KitID" type="String" default="something" />

Tried all that, but it still disables the extension when files are generated. Here’s my current XML definition:

<?xml version="1.0" encoding="iso-8859-1" ?>
<ew-extension name="FontAwesomePro" version="17.0.0" type="Font Awesome Pro" author="Brad S Konia">
	<description>
		<![CDATA[
			Enables Font Awesome Pro
		]]>
	</description>
	<file>fontawesomepro.zip</file>
	<Project>
    	<Attribute name="KitID" type="String" default="123" />
	</Project>
</ew-extension>

and here’s my current layout.php:

<#
	let ext = GetExtensionObject("FontAwesomePro"); // Get extension object by extension name
    if (ext.Enabled && ext.Proj) { // If extension enabled
        myKitID = ext.PROJ.KitID;
        args.code = args.code.replace('<link rel="stylesheet" type="text/css" href="<?= $basePath ?>plugins/fontawesome-free/css/all.min.css">', '<script src="https://kit.fontawesome.com/' + myKitID + '.js" crossorigin="anonymous"></script>');
    }
#>

Could you please test it on your end and see if you get the same result?

I’ve just tested it, and the Extensions is running well (keep enabling, and not disabling as yours).However, the code in the generated layout.php is not changed, even I have already changed this code:
''to:
''since the code in layout.php of latest template does not include type=“text/css” anymore.