Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Header configuration & styling (http://forum.bytesforall.com/forumdisplay.php?f=15)
-   -   Using bar1 or bar2 for Javascript? (http://forum.bytesforall.com/showthread.php?t=3649)

paulae Sep 29, 2009 04:40 PM

Using bar1 or bar2 for Javascript?
 
In trying to make my page load faster, and especially to make the very beginning of the page to show up faster without a long lag-time, I'm trying to make the things that load first be very light-weight. I had a plugin in the left sidebar to show the current date, as any news site should have. Plugins seem to be rather heavy in the way they use the browser, so I am looking for another way. Ideally, I would like the date to show up below the top banner ad, which would be a nice location for bar1. I would like to be able to put Javascript in there, like this:
Quote:

<script language="javascript" type="text/javascript">
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thu rsday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May"," June","July","August","September","October","Novem ber","December")
document.write("<small><font color='FFFFFF' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b></font></small>")
</script>
At the moment, I've inserted it into the HTML Insert area for the header, and it's showing up at the very top of the container. Not where I want it, ultimately.

Any way I can do what I want? I saw a thread earlier about putting text in the /functions/bfa_ata_header_config.php file where the bar code is, but I don't know how to put Javascript there without ending up with an ugly parse error.

BradBrown Sep 29, 2009 06:18 PM

You don't have to use Javascript at all. Another option is to use PHP to populate the date on the server side. Just put something like the following where you want the date to show up:

PHP Code:

<?php echo date("l F j, Y");?>

(Of course, this has to be somewhere you're allowed to use PHP--like many of the ATA areas or in a PHP widget.)

This would make your pages a bit smaller, and make the date show up even if the user has Javascript turned off.

paulae Sep 30, 2009 05:11 AM

Hi, and thanks.

Yes, I had a PHP plugin in a widget in the left sidebar, showing the date. I was trying to get rid of as many plugins as possible, so at least your method would dispense with one, while still showing the date.

I get the idea of showing the date even if the user's JS is turned off, but there is so much JS all over the theme, and I guess in Wordpress, that surely that can't be much of an issue.

I'm also trying to avoid adding code to the theme files except via the theme options. Those who will manage the site after me are not going to feel comfortable doing that, I know.

BradBrown Sep 30, 2009 11:47 AM

You don't have to edit theme files or use a plug-in. You said you wanted to put it in the header. You can put the PHP code (or the Javascript, for that matter) directly in the ATA Options->Style & Configure HEADER AREA->Configure Header Area box.

I just mentioned the PHP widget because it might be useful to others who read this thread.


All times are GMT -6. The time now is 08:28 PM.

Powered by vBulletin® Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.