JS Changing Title & Breadcrumbs and More

The following changes the page title to "Publications" and changes the breadcrumbs to "Home / Resource Library" w/ their corresponding links: 

<script type="text/javascript">

var PageTitle = 'Publications' ;

//DO NOT EDIT BELOW THIS
document.getElementById("page-title").innerHTML = PageTitle;

var txt = document.getElementsByClassName("breadcrumb")[0].innerHTML;
var txt1 = '<a href=\"https://hwpi.harvard.edu/govlabs/home">Home</a>' + '<span> / </span>' + '<a href=\"https://hwpi.harvard.edu/govlabs/resource-library">Resource Library</a>' + '<span> / </span>';
document.getElementsByClassName("breadcrumb")[0].innerHTML = txt1;

</script>

 

The following just changes the title of an app or listing page:

<script type="text/javascript">

var PageTitle = 'Publications' ;

//DO NOT EDIT BELOW THIS
document.getElementById("page-title").innerHTML = PageTitle;

</script>

 

The following changes just the breadcrumbs of a page:

 

<script type="text/javascript">

var txt = document.getElementsByClassName("breadcrumb")[0].innerHTML;

//edit this part
var txt1 = '<a href=\"https://hwpi.harvard.edu/govlabs/home">Home</a>' + '<span> / </span>' + '<a href=\"https://hwpi.harvard.edu/govlabs/resource-library">Resource Library</a>' + '<span> / </span>';
//end edit this part

document.getElementsByClassName("breadcrumb")[0].innerHTML = txt1;

</script>

 

 

Use this if want the list view pages to change the title, but the detail view pages to only change the breadcrumbs (e.g., Titles for the Classes app, so the course titles don't change when on a detail page for the class)

<script type="text/javascript">

//IF page is an app list view page, change page title to "Courses"
var listPage = document.getElementsByClassName("apachesolr_search-results");
if (listPage[0]) {
    
    var PageTitle = 'Courses' ;
    document.getElementById("page-title").innerHTML = PageTitle;
    
} else {
//if not, only change breadcrumbs to "Courses"

    var brdcrbTxt1 = document.getElementsByClassName("breadcrumb")[0];

    var brdcrbTxt2 = '<a href=\"https://projects.iq.harvard.edu/gened2">Home</a>' + '<span> / </span>' + '<a href=\"https://projects.iq.harvard.edu/gened2/courses-listing">COURSES</a>' + '<span> / </span>';

    brdcrbTxt1.innerHTML = brdcrbTxt2;
}

</script>

 

Changing Dropdown menu title for Taxonomy widget

<script>

var dropList1 = 'edit-terms-12409';
//var dropList2 = 'edit-terms-6376';

//set the first line
var dropTitle1 = document.getElementById(dropList1).getElementsByTagName("option")[0].innerHTML = 'Choose a seminar';
//var dropTitle2 = document.getElementById(dropList2).getElementsByTagName("option")[0].innerHTML = 'Select a term';

</script>

 

See also: Content