Setting Home Page link Dynamically
I have changed my plan for the Village Hall website since I wrote this page. I now intend to use the Wordpress implementation exclusively and the bwvh.uk pages are now parked. This page is an example of how the home page is programatically set. In this case the home page is set to the Parish Council website.
The original plan
As an interim method of using the Village Hall Wordpress as a "front-end" for a re-written site I want to set the home page to the Wordpress site on pages where I am doing some more sophisticated css and Javascript. When I get the domain under my control I may well still want to continue the Wordpress site to handle forms and commuicaitons.
The way that I want(ed) this to work is that when I get control of the Domain I will change the script to set the Home Page to the new Home page. Having the dynamic function will mean that I don't need to change all the files on BWVH (or belchampwaltervillgehall.co.uk - the Wordpress site then maps to bwvh.uk ???? I need to think this out).
The code - Adding Contact Links
Again, manipulation of the DOM comes into play.
Having added links to set Contact pages to the template for the Village Hall site it was apparent that you have to be careful when changing the setAttribute Javascripts in the script file. If id's cannot be found the function fails and none of the settings are set. i.e. if a contact link is removed from the top menu the one on the bottom has to become the first. Actually, the function executes until it gets an error and then crashes, this was only apparent when I started adding links to my own contact code - flying in the face of spammers!
The Home page of the Village Hall
This page has its home page set to the VH, as are the bwvh.uk pages.
DO NOT CLICK as it will mess with the stats!
The Code
The JavaScript to manipulate the menu links.......
function set_home() {
// WARNING - make sure the ids are all correct in the menus or setAttribute will fail
var a = document.getElementById("home_link");
a.setAttribute("href", "index.html"); // a.href="index.html:;
var b = document.getElementById("home_link1");
b.setAttribute("href", "index.html"); // b.href="index.html:;
var c = document.getElementById("contact_link1");
c.setAttribute("href", "#"); // c.href="contact_vh.html https://belchampwaltervillagehall.co.uk/correo/:
var d = document.getElementById("contact_link2");
d.setAttribute("href", "#"); // d.href="contact_vh.html:
// probably need to about links}
Looking back it seems that the only place that I seemed to have used this was on a picture gallery for the Valentine's meal for 2020.