PHP Plugins/ custom font issues

Trying to using a MyFonts Kit for my masthead type. Have followed all instructions gleaned from previous posts here, as well as in the Backlight docs.

A couple of questions:

  1. if I am not using Google fonts, the optional Google Fonts Statement box should be empty, or does it matter?

  2. in the custom phplugins file I created (by copying the sample file and adding in the head function in the proper place below user settings) doe I need to have the " return false" words in there at the end? In all the samples you show, I see that. Even in the Backlight docs page. Yet in Rod’s Adding Fonts Instruction page I do not see it.

Here is my phplugins page - from user settings area to end of page. Everything above was untouched from the sample file:

```
// SET USER FUNCTIONS BELOW
// Some example functions are included below. Feel free to delete or modify unwanted functions.
// ****************************************************************************************************


function head() {
echo '
<link rel="stylesheet" type="text/css" href="/backlight/custom/fonts/MyFontsWebfontsKit.css">
';
} // END /**/


// ****************************************************************************************************
// END USER FUNCTIONS

?>
```

I could show everything else, but I have gone through everything multiple times to get all he details right. Here is the link to the site iI am trying to implement this. The default identity font is courier. I have entered the font family name into the PrePend Box. Any suggestions?

If not using Google fonts then leave that field empty

in the head hook, the return value is ignored, so no need for return false; or return true;

Looks like your phplugins function is correct yet I don’t see the html appearing in the head section of the page you linked to. Did you assign the phplugins file to the page template under Advanced Setup?

Thanks, Rod. I did read your article that you referenced, That was my guide, as I purchased the font set from MyFonts. I followed all the details as you laid them out, but can’t seem to get the fonts to load.

I did make sure the Page Template was toggled to the correct php file.

Well, the code is not being inserted into the page. Did you start out with the phplugins-pangolin-sample.php file?

Yes, I did.

Maybe I’ll try again from scratch. I must have missed something in the process.

Double check that you’ve assigned the phplugins file to page template that is controlling the album set that controls the page you linked to. The page template id is 27 (you can see this by looking at the body tag in the source code, it’s one of the classes). You can see the page template id number by hovering over the link to in in Backlight > Templates and looking at the end of the url in the url preview that appears at the bottom of the browser:

Yes, those seemed to match. Although I did see two ids listed in line together - 22 and 24(?).

But I discovered (as the id hover trick you referred to did not work in my version of Safari (14.0.3) that upon opening the page in Chrome - the new font is there in the masthead!. But I can’t see the references to the fonts in the /head.

Going back to over Safari, still a no go. No cahnge in the code, just how the browsers are handling it. Any ideas?

Do you have the font installed on your computer? If so, that’s probably why you’re seeing it. I’m not seeing it in Firefox or Chrome.

There are usually a couple of ID numbers in the body tag. One is the page template and the other is the album set template.

I can’t really tell any more without looking closer. If you want, I can take a look. Just message me Backlight admin or guest updater credentials. You can message me by clicking on my name or icon above this message.

It also might help if you post the entire contents of your phplugins file.

Ah, yes, I do have it on my computer. Forgot about that possibility.

Thanks on the ID #s - they are both correct.

Here is the entire code for the phplugins file:

<?php
/*
 *	TTG Core Elements "PHPlugins" User Hooks v1.2 - initialization mainline
 *
 *	developed by john bishop images (http://johnbishopimages.com)
 *	for Matthew Campagna of The Turning Gate (http://theturninggate.net)
 *
 */

function ttg_user_load( $style, $path ) {
	$g_tsvrl = explode( ' ', $style );                          // Extract gallery type
	define ( 'G_STYLE', strtoupper($g_tsvrl[1]) );              // and set global for later
	$g_path = str_ireplace('\\','/',$path);                     // change \ to / 
	$chunks = explode('/',$g_path);                             // and put into array
	define ( 'G_PATH', strtoupper($chunks[count($chunks)-2]) ); // gallery folder name is second to last
	//define ( 'TTG_SITE', '');                                   // set new site root for navigation, resources, etc.
	}

/*
 *	
 *	*************************************************************************************
 *	*                                                                                   *
 *	* Warning! When using echo or print special care must be qiven to using quotes.     *
 *	*                                                                                   *
 *	* Strings inside single quotes must contain only double quotes                      *
 *	* or all single quotes must be escaped (ie \') or vice-versa                        *
 *	*                                                                                   *
 *	*************************************************************************************
 *	
 *	Fourteen user exits are defined in all web engines - all are optional 
 *		(i.e. ttg_user_load.php may be the only processing)
 *		
 *	Some web engines will have additional exits defined, specific to that gallery type
 *		
 *	Each is called with the same parameters:
 *		%1	-	TTG gallery-style gallery-release
 *				3 blank delimited values
 *				- %1.1	-	'TTG'
 *				- %1.2	-	string describing gallery type; no embedded blanks
 *				- %1.3	-	a series of two to three period delimited integers
 *							describing gallery release level; x.y or x.y.z
 *		%2	-	server filesystem file name and path of calling file
 *		
 *
 *	Defined exits:
 *
 *		ttg_user_load			
 *      - return value ignored
 *      - called immediately after this file returns
 *      - called before any output is produced
 *      - all header and response variables are accessible
 *      - cookie and session processing can be initialized
 *      - globals to be used by later hook calls can be defined 
 *
 *    ttg_head
 *      - return value ignored
 *      - called immediately before </head>
 *      - encompasses nothing; use to insert content into the <head>
 *
 *    ttg_header_top
 *      - if return=false, the contents of the normal Backlight header are skipped
 *      - called immediately within the header section
 *      - encompasses the full contents of the header section; can be used to replace those contents
 *
 *    ttg_header_bottom
 *      - return value ignored
 *      - called last in the header section
 *      - encompasses nothing; use to insert content at the end of the header section
 *
 *    ttg_masthead_primary_top
 *      - if return=false, normal Backlight masthead is skipped
 *      - called immediately before the masthead element
 *      - fully encompasses the masthead; can be used to replace it
 *
 *    ttg_masthead_primary_bottom
 *      - return value ignored
 *      - called immediately after the masthead
 *      - encompasses nothing; use to insert content after the masthead
 *
 *    ttg_masthead_secondary_top
 *      - if return=false, normal Backlight masthead is skipped
 *      - called immediately before the masthead element
 *      - fully encompasses the masthead; can be used to replace it
 *
 *    ttg_masthead_secondary_bottom
 *      - return value ignored
 *      - called immediately after the masthead
 *      - encompasses nothing; use to insert content after the masthead
 *
 *    ttg_navigation
 *      - if return=false, normal Backlight navigation is skipped
 *      - navigation is separate from the header section, so not affected by the above ttg_header... hooks.
 *      - encompasses the navigation <ul> element; can be used to replace it
 *
 *    ttg_main_top
 *      - return value ignored
 *      - called immediately within the main content column
 *      - encompasses nothing; use to insert content at the very top of the main content column
 *      - located outside the password protected area
 *
 *    ttg_main_bottom
 *      - return value ignored
 *      - called immediately before closing the main content column
 *      - encompasses nothing; use to insert content at the very bottom of the main content column
 *      - located outside the password protected area
 *
 *    ttg_footer_top
 *      - if return=false, the contents of the normal Backlight footer are skipped
 *      - called immediately within the footer section
 *      - encompasses the full contents of the footer section; can be used to replace those contents
 *
 *    ttg_footer_bottom
 *      - return value ignored
 *      - called last in the footer section
 *      - encompasses nothing; use to insert content at the end of the footer section
 *
 *    ttg_pallet_top_title
 *      - if return=false, the encompassed code is skipped
 *      - wraps the site title in the top pallet
 *      - use to replace the site title
 *
 *    ttg_toggle_T1
 *      - if return=false, the encompassed code is skipped
 *      - wraps the label element for "page__toggle__T1"
 *      - use to replace the toggle button with one of your own making
 *
 *    ttg_toggle_T2
 *      - if return=false, the encompassed code is skipped
 *      - wraps the label element for "page__toggle__T2"
 *      - use to replace the toggle button with one of your own making
 *
 *    ttg_social_top
 *      - if return=false, normal content is skipped
 *      - called immediately before social media icons in the top pallet
 *      - encompasses the social media icons; can be used to replace them
 *
 *    ttg_social_bottom
 *      - return value ignored
 *      - called immediately after social media icons in the top pallet
 *      - encompasses nothing; use to insert content following the social media icons
 *
 *    ttg_scripts
 *      - return value ignored
 *      - called immediately before </body>
 *      - encompasses nothing; use to insert content at the very bottom of the page
 *
 *    ttg_copy_top
 *      - if return=false, normal copy is skipped
 *      - called immediately within the page copy area
 *      - encompasses the page copy; can be used to replace it
 *
 *    ttg_copy_bottom
 *      - return value ignored
 *      - called immediately before closing the page copy area
 *      - encompasses nothing; use to insert content following the page copy
 *
 *    ttg_pallet01_top
 *      - if return=false, pallet content is skipped
 *      - called within pallet01, after masthead and navigation
 *      - encompasses the pallet01 content area
 *
 *    ttg_pallet01_bottom
 *      - return value ignored
 *      - called after the pallet01 content
 *      - encompasses nothing; use to insert content at the end of pallet01
 *
 *    ttg_pallet02_top
 *      - if return=false, pallet content is skipped
 *      - called within pallet02, after masthead and navigation
 *      - encompasses the pallet02 content area
 *
 *    ttg_pallet02_bottom
 *      - return value ignored
 *      - called after the pallet02 content
 *      - encompasses nothing; use to insert content at the end of pallet02
 *
 *    ttg_albumset_top
 *      - if return=false, normal copy is skipped
 *      - called immediately within the media area
 *      - encompasses the gallery grid / slideshow; can be used to replace it
 *
 *    ttg_albumset_bottom
 *      - return value ignored
 *      - called immediately before closing the media area
 *      - encompasses nothing; use to insert content following the gallery grid / slideshow
 *
 *    ttg_album_top
 *      - if return=false, the album content is skipped
 *      - called immediately within the media area
 *      - encompasses the album grid / slideshow; can be used to replace it
 *
 *    ttg_album_bottom
 *      - return value ignored
 *      - called immediately before closing the media area
 *      - encompasses nothing; use to insert content following the album grid / slideshow
 *
 *    ttg_single_top
 *      - if return=false, single image and content are skipped
 *      - called immediately above the single image display
 *      - encompasses the single image and related metadata; can be used to replace it
 *      - available only on single-image HTML pages for applicable album templates
 *
 *    ttg_single_bottom
 *      - return value ignored
 *      - called after the single image display
 *      - encompasses nothing; use to insert content following the single image display
 *      - available only on single-image HTML pages for applicable album templates
 *
 */


// SET USER FUNCTIONS BELOW
// Some example functions are included below. Feel free to delete or modify unwanted functions.
// ****************************************************************************************************


function head() {
echo '
<link rel="stylesheet" type="text/css" href="/backlight/custom/fonts/MyFontsWebfontsKit.css">
';
} // END /**/


// ****************************************************************************************************
// END USER FUNCTIONS

?>

Let’s see if you can spot an error here. If not I’ll message you. Thanks, Rod.

You’re using the wrong phplugins file. You need to start with the one named phplugins-pangolin-sample.php. Then your code should work.

Ok - that is strange. Here is the phplugins-pangolin-sample.php file I have in the phplugins folder:

<?php
/*
 *	TTG Core Elements "PHPlugins" User Hooks v1.2 - initialization mainline
 *
 *	developed by john bishop images (http://johnbishopimages.com)
 *	for Matthew Campagna of The Turning Gate (http://theturninggate.net)
 *
 */

function ttg_user_load( $style, $path ) {
	$g_tsvrl = explode( ' ', $style );                          // Extract gallery type
	define ( 'G_STYLE', strtoupper($g_tsvrl[1]) );              // and set global for later
	$g_path = str_ireplace('\\','/',$path);                     // change \ to / 
	$chunks = explode('/',$g_path);                             // and put into array
	define ( 'G_PATH', strtoupper($chunks[count($chunks)-2]) ); // gallery folder name is second to last
	//define ( 'TTG_SITE', '');                                   // set new site root for navigation, resources, etc.
	}

/*
 *	
 *	*************************************************************************************
 *	*                                                                                   *
 *	* Warning! When using echo or print special care must be qiven to using quotes.     *
 *	*                                                                                   *
 *	* Strings inside single quotes must contain only double quotes                      *
 *	* or all single quotes must be escaped (ie \') or vice-versa                        *
 *	*                                                                                   *
 *	*************************************************************************************
 *	
 *	Fourteen user exits are defined in all web engines - all are optional 
 *		(i.e. ttg_user_load.php may be the only processing)
 *		
 *	Some web engines will have additional exits defined, specific to that gallery type
 *		
 *	Each is called with the same parameters:
 *		%1	-	TTG gallery-style gallery-release
 *				3 blank delimited values
 *				- %1.1	-	'TTG'
 *				- %1.2	-	string describing gallery type; no embedded blanks
 *				- %1.3	-	a series of two to three period delimited integers
 *							describing gallery release level; x.y or x.y.z
 *		%2	-	server filesystem file name and path of calling file
 *		
 *
 *	Defined exits:
 *
 *		ttg_user_load			
 *      - return value ignored
 *      - called immediately after this file returns
 *      - called before any output is produced
 *      - all header and response variables are accessible
 *      - cookie and session processing can be initialized
 *      - globals to be used by later hook calls can be defined 
 *
 *    ttg_head
 *      - return value ignored
 *      - called immediately before </head>
 *      - encompasses nothing; use to insert content into the <head>
 *
 *    ttg_header_top
 *      - if return=false, the contents of the normal Backlight header are skipped
 *      - called immediately within the header section
 *      - encompasses the full contents of the header section; can be used to replace those contents
 *
 *    ttg_header_bottom
 *      - return value ignored
 *      - called last in the header section
 *      - encompasses nothing; use to insert content at the end of the header section
 *
 *    ttg_masthead_primary_top
 *      - if return=false, normal Backlight masthead is skipped
 *      - called immediately before the masthead element
 *      - fully encompasses the masthead; can be used to replace it
 *
 *    ttg_masthead_primary_bottom
 *      - return value ignored
 *      - called immediately after the masthead
 *      - encompasses nothing; use to insert content after the masthead
 *
 *    ttg_masthead_secondary_top
 *      - if return=false, normal Backlight masthead is skipped
 *      - called immediately before the masthead element
 *      - fully encompasses the masthead; can be used to replace it
 *
 *    ttg_masthead_secondary_bottom
 *      - return value ignored
 *      - called immediately after the masthead
 *      - encompasses nothing; use to insert content after the masthead
 *
 *    ttg_navigation
 *      - if return=false, normal Backlight navigation is skipped
 *      - navigation is separate from the header section, so not affected by the above ttg_header... hooks.
 *      - encompasses the navigation <ul> element; can be used to replace it
 *
 *    ttg_main_top
 *      - return value ignored
 *      - called immediately within the main content column
 *      - encompasses nothing; use to insert content at the very top of the main content column
 *      - located outside the password protected area
 *
 *    ttg_main_bottom
 *      - return value ignored
 *      - called immediately before closing the main content column
 *      - encompasses nothing; use to insert content at the very bottom of the main content column
 *      - located outside the password protected area
 *
 *    ttg_footer_top
 *      - if return=false, the contents of the normal Backlight footer are skipped
 *      - called immediately within the footer section
 *      - encompasses the full contents of the footer section; can be used to replace those contents
 *
 *    ttg_footer_bottom
 *      - return value ignored
 *      - called last in the footer section
 *      - encompasses nothing; use to insert content at the end of the footer section
 *
 *    ttg_pallet_top_title
 *      - if return=false, the encompassed code is skipped
 *      - wraps the site title in the top pallet
 *      - use to replace the site title
 *
 *    ttg_toggle_T1
 *      - if return=false, the encompassed code is skipped
 *      - wraps the label element for "page__toggle__T1"
 *      - use to replace the toggle button with one of your own making
 *
 *    ttg_toggle_T2
 *      - if return=false, the encompassed code is skipped
 *      - wraps the label element for "page__toggle__T2"
 *      - use to replace the toggle button with one of your own making
 *
 *    ttg_social_top
 *      - if return=false, normal content is skipped
 *      - called immediately before social media icons in the top pallet
 *      - encompasses the social media icons; can be used to replace them
 *
 *    ttg_social_bottom
 *      - return value ignored
 *      - called immediately after social media icons in the top pallet
 *      - encompasses nothing; use to insert content following the social media icons
 *
 *    ttg_scripts
 *      - return value ignored
 *      - called immediately before </body>
 *      - encompasses nothing; use to insert content at the very bottom of the page
 *
 *    ttg_copy_top
 *      - if return=false, normal copy is skipped
 *      - called immediately within the page copy area
 *      - encompasses the page copy; can be used to replace it
 *
 *    ttg_copy_bottom
 *      - return value ignored
 *      - called immediately before closing the page copy area
 *      - encompasses nothing; use to insert content following the page copy
 *
 *    ttg_pallet01_top
 *      - if return=false, pallet content is skipped
 *      - called within pallet01, after masthead and navigation
 *      - encompasses the pallet01 content area
 *
 *    ttg_pallet01_bottom
 *      - return value ignored
 *      - called after the pallet01 content
 *      - encompasses nothing; use to insert content at the end of pallet01
 *
 *    ttg_pallet02_top
 *      - if return=false, pallet content is skipped
 *      - called within pallet02, after masthead and navigation
 *      - encompasses the pallet02 content area
 *
 *    ttg_pallet02_bottom
 *      - return value ignored
 *      - called after the pallet02 content
 *      - encompasses nothing; use to insert content at the end of pallet02
 *
 *    ttg_albumset_top
 *      - if return=false, normal copy is skipped
 *      - called immediately within the media area
 *      - encompasses the gallery grid / slideshow; can be used to replace it
 *
 *    ttg_albumset_bottom
 *      - return value ignored
 *      - called immediately before closing the media area
 *      - encompasses nothing; use to insert content following the gallery grid / slideshow
 *
 *    ttg_album_top
 *      - if return=false, the album content is skipped
 *      - called immediately within the media area
 *      - encompasses the album grid / slideshow; can be used to replace it
 *
 *    ttg_album_bottom
 *      - return value ignored
 *      - called immediately before closing the media area
 *      - encompasses nothing; use to insert content following the album grid / slideshow
 *
 *    ttg_single_top
 *      - if return=false, single image and content are skipped
 *      - called immediately above the single image display
 *      - encompasses the single image and related metadata; can be used to replace it
 *      - available only on single-image HTML pages for applicable album templates
 *
 *    ttg_single_bottom
 *      - return value ignored
 *      - called after the single image display
 *      - encompasses nothing; use to insert content following the single image display
 *      - available only on single-image HTML pages for applicable album templates
 *
 */


// SET USER FUNCTIONS BELOW
// Some example functions are included below. Feel free to delete or modify unwanted functions.
// ****************************************************************************************************




/* DELETE THIS LINE
function _HOOK_( $style, $path ) { 
	echo '

	';
	return false;
} // END /**/




/* DELETE THIS LINE
function ttg_main_top( $style, $path ) { 
	echo '<ul style="background-color:#FFF9C4;color:#000;margin:1.5rem 0;padding:24px 36px;">';
		if (PASSWORD_ENABLED) {
			echo '<li><strong>This gallery is private</strong>.</li>';
			if (LOGGED_IN) {
				echo '<li><small>The user is logged in</small>.</li>';
			} else {
				echo '<li><small>The user is logged out</small>.</li>';
			}
		} else {
			echo '<li><strong>This gallery is public</strong>.</li>';
		}
	echo '</ul>';
	return false;
} // END /**/




/* DELETE THIS LINE
function ttg_toggle_T1( $style, $path ) { 
	// Below, the bare minimum markup required for functioning toggles;
	// fill in the LI element as you wish. Custom CSS may be necessary.
	echo '

	<label for="page__toggle__T1">
		<ul><li></li></ul>
	</label> 

	';
	return false;
} // END /**/




/* DELETE THIS LINE
function ttg_pallet_top_title( $style, $path ) { 
	// Below, the default markup for the title. The LI wrapping element is mandatory;
	// replace the inner HTML as you see fit. Retain the "masthead_pallet_top" class and styling,
	// or assign a new class, with styling defined in custom CSS.
	// Take note, the top pallet height is a 48px fixed value.
	echo '

	<li class="masthead_pallet_top">
		<h1><a href="/">Your Site Title</a></h1>
	</li>

	';
	return false;
} // END /**/




/* DELETE THIS LINE
function ttg_navigation( $style, $path ) { 
	echo '
	<ul class="primary-menu menu mouseable">
		<li class="menu-item"><a href="/">Home</a></li>
		<li class="menu-item menu-item-has-children"><a href="/galleries">Galleries</a>
			<ul class="sub-menu">
				<li class="menu-item"><a href="">Sub-item 1</a></li>
				<li class="menu-item"><a href="">Sub-item 2</a></li>
				<li class="menu-item"><a href="">Sub-item 3</a></li>
				<li class="menu-item"><a href="">Sub-item 4</a></li>
				<li class="menu-item"><a href="">Sub-item 5</a></li>
				<li class="menu-item"><a href="">Sub-item 6</a></li>
				<li class="menu-item"><a href="">Sub-item 7</a></li>
				<li class="menu-item"><a href="">Sub-item 8</a></li>
			</ul>
		</li>
		<li class="menu-item"><a href="/blog">Blog</a></li>
		<li class="menu-item"><a href="/about">About</a></li>
		<li class="menu-item"><a href="/contact">Contact</a></li>
	</ul>
	';
	return false;
} // END /**/




/* DELETE THIS LINE
// Adding new social media icons before ... 
function ttg_social_top( $style, $path ) { 
	echo '

	<li><a target="_blank" href="" class="social_media fa fa-google-plus"></a></li>

	';
	return true;
} // END

// ... and after.
function ttg_social_bottom( $style, $path ) { 
	echo '

	<li><a target="_blank" href="" class="social_media fa fa-pinterest"></a></li>
	<li><a target="_blank" href="" class="social_media fa fa-instagram"></a></li>

	';
} // END /**/




/* DELETE THIS LINE
// Highlight menu item for current page 
function ttg_scripts( $style, $path ) { 
echo <<<SCRIPT
	<script>
	$("ul.menu a[href='" + window.location.pathname + "']")
		.parentsUntil('.menu', 'li')
		.addClass("current_page_item")
		;
	</script>
SCRIPT;
	return false;
} // END /**/




// ****************************************************************************************************
// END USER FUNCTIONS

?>

Is this not the same (aside from my user edits)?

you need to use the latest one (Backlight 2 and newer). If your installation of Backlight 3 is up to date you can get it by downloading it via ftp from your site at /backlight/modules/custom-resources/phplugins/.

You can also get it from your unzipped download of the Backlight-3-installer-114.zip (or earlier) folder (Backlight-3-installer-xxx/backlight/custom/phplugins/)

Thanks, Rod. I will locate the new one and try with that. I am on the latest Backlight 3 version. Appreciate your help, as always.