Swapping out Font Awesome Icons in a TTG page

Recently on the TTG Community Forum, a user asked about being able to replace the standard GPS Google Map marker icon used in TTG CE3 Gallery with a globe icon, like the one that was used with the CE2 version of TTG Gallery.

The gps icon, like all icons in CE3 is a Font Awesome icon (icon-map-marker). And it looks like it’s hard coded into the TTG CE3 Gallery web-engine. So we’re looking to replace that icon with something else. Turns out there is a globe Font Awesome icon that will serve the purpose (icon-globe) .

Since Font Awesome icons are placed using the code <i class="icon-name-of-icon"></i> ( a class applied to the “i” html tag) that means we need to replace the existing class named “icon-map-marker” with the “icon-globe” class.
I can think of one relatively easy way to remove and add classes and that’s using JQuery. I’ll use a little snippet of code to remove the class “icon-map-marker” from that “i” tag then add the class “icon-globe” to it.
Here’s the code:


<script>
$(document).ready(function(){
$(".map-marker i").removeClass("icon-map-marker").addClass("icon-globe");
});
</script>

Here’s what’s happening. That first part, the <script> tag, is needed to tell the browser that a script is coming. The first line of the actual script just tells jQuery to wait until the page loads before executing what follows.
The magic happens in the next line. The script is basically saying: Look for the indicated selector (in this case, the “i” tag inside of a class named “map-marker”), remove the class “icon-map-marker” from the tag and add the class “icon-globe”.
Next, the closing </script> tag tells the browser that the script is ended.

To accomplish this, you’ll first need to enable phplugins. The instructions for doing so can be found here. Once you’ve done this, open your global phplugins.php file with a plain text editor and insert the above code using the ttg_head_end hook. You can just add the code right after the code that enables custom css. You’ll see this once you open the phplugins.php file.
You can learn more about editing and using phplugins starting here.

The whole thing inside of the ttg_head_end function in the phplugins.php file will look like this:


function ttg_head_end( $style, $path ) {
echo '
<link href="/phplugins/css/custom.css" rel="stylesheet" />

<script>
$(document).ready(function(){
$(“.map-marker i”).removeClass(“icon-map-marker”).addClass(“icon-globe”);
});
</script>
‘; //script to swap Font Awesome GPS icons
} // END

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About this site

This site is: a repository of time-savers and best practices from a user's perspective, picked up from several years of using TTG plugins.
This site is not: a support site.
Read more here.

Subscribe to new posts

Tip Jar

If this site has saved you some time, kept your hair attached, or otherwise prevented you from tossing the mouse through the monitor, feel free to donate.

Categories


Highly recommended. This is my go-to Lightroom book. Click on the book image. (affiliate link)

Affiliate link!

Current TTG versions

Backlight  4 & 5

See the Backlight Modules page on your site for latest Backlight and module versions and changelogs.

You’ll also find the latest version number and download link for the Lightroom Publisher plugin.
(BL 3 and later)

 

Backlight 1 Versions

Backlight 1.2.4
Pages module 1.2.4
Cart Add-on 4.1.7
Client Response Add-on 7.1.3
Theater Add-on 1.2.6
Galleria Add-on 1.0.0
WordPress Add-on 1.2.6
Publisher 3.2.3

Backlight 1 has seen its end of life. See this post.

CE4 Versions

note: CE4 is no longer being developed or sold. See this post.

TTG-BE: 2.0.5a
Autoindex: 7.0.8
Cart: 3.1.4a
CRG: 6.1.3a
Gallery: 6.1.10
Pages: 7.0.15
Publisher: 2.3.3
Stage: 6.1.6
Theme for WordPress: 3.1.2