Jump to content
create

positioning of custom script.

Recommended Posts

create

Take a look at my site http://tinyurl.com/cosv8ge

I'm trying to change the position of a custom script that I installed into the header scripts. The script displays a custom greeting on the site depending on the time of day. I want the greeting to be above the telephone number in the header but i'm struggling to achieve this.

The script is as follow:


<span class="xdate"><?php echo date('l jS F Y'); ?></span>

<script language="Javascript" type="text/javascript">

<!--

var day = new Date();

var hr = day.getHours();

if (hr <= 11)

   {

   document.write("Good Morning...");

   }

else if (hr > 11 && hr < 17)

   {

   document.write("Good Afternoon...");

   }

else

   {

   document.write("Good Evening...");

   }


//-->

</script>

Can anyone help?

thanks

James UK

Share this post


Link to post
Share on other sites
Danny

Hi,

You would need to wrap in a div to position it however, Javascript isn't really my forte.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
create

I have managed to wrap it in a div, but i'm struggling to:

1. bring the div to the front, so it sits on top of the header

2. It's currently set to 50px off the right but its doing this off the side of the browser window, rather than the right hand side of the web page

grateful for any help

Share this post


Link to post
Share on other sites
catrina

1. You may need to adjust the z-index: http://www.w3schools.com/cssref/pr_pos_z-index.asp

2. The left/right margins need to be changed: http://www.w3schools.com/css/css_margin.asp

Please see this documentation for further instructions: http://www.pagelines.com/wiki/Custom_CSS


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
create

thanks for the replies, I have managed to position the div on top now with an outlandish z-index figure of 999. I'm still having trouble with positioning the div above the phone number in the header. The margins seem to be working off the edge of the browser window rather than the edge of the web pages? any ideas how i define that??

Share this post


Link to post
Share on other sites
evan

Scripts that output stuff for display on the page like this really don't belong in the headerscripts as it will output in the <head> tag. You're better off adding this code with a php hook in your child theme's functions.php file.


<?php

add_action('pagelines_inside_top_branding', 'branding_greeting');

function branding_greeting() {

?><div id="custom_greeting">

<script type="text/javascript">

<!--

var day = new Date();

var hr = day.getHours();

if (hr <= 11)

	 {

	 document.write("Good Morning...");

	 }

else if (hr > 11 && hr < 17)

	 {

	 document.write("Good Afternoon...");

	 }

else

	 {

	 document.write("Good Evening...");

	 }


//-->

</script>

</div>

<?php

}

That will get you a lot closer to where you want it, and then you won't need such hardcore CSS to wrestle it into place.

Hope that helps :)

Share this post


Link to post
Share on other sites
create

Hi Evan, thanks for your reply.

I added your code to the functions.php file located in /wp-content/themes/pagelines/functions.php

and was returned with the following error when I reloaded the page...

Parse error: syntax error, unexpected '<' in /websites/123reg/LinuxPackage22/ll/oy/ds/lloydspropertyagents.com/public_html/wp-content/themes/pagelines/functions.php on line 24

Any ideas?

thanks

J

Share this post


Link to post
Share on other sites
Rob

Evan didn't point you to the correct functions.php. Please remove the code from where you placed it.

The code he provided should work if you have the pagelines-customize plugin installed. In there, you'll find a functions.php. Just tack his code at the end.

Alternatively, if you're using a child theme, like Base, you can use the functions.php inside the child theme folder.

You'll get errors when using the core files.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Similar Content

    • chamois_blanc
      By chamois_blanc+
      Hello,
      Shouldn't the image PL5 component be using the srcset/picture css directives to pick the correct size for an image? or it does already and I don't know how to use it? Thank you for any advice or enlightenment.
    • Dan Haddock
      By Dan Haddock
      Plugins Active and installed: 
      Akismet Anti-Spam
      Coming Soon Page & Maintenance Mode by SeedProd
      Contact Form 7
      Cookie Law Info
      DMS Professional Tools  
      Enhanced Media Library  
      Flamingo
      Google Analytics for WordPress by MonsterInsights
      Google XML Sitemap
      Jetpack by WordPress.com
      Legull 
      Loginizer   
      MailChimp for WordPress
      PageLines Updater    
      Schema App Structured Data 
      Sucuri Security - Auditing, Malware Scanner and Hardening
      Uber reCaptcha    
      Yoast SEO
      Wordpress Version: 4.8.1
      Pagelines Version: 2.2.4
       
      Good Evening/Afternoon or Morning, 
      I am running into a problem with CSS styling not applying inside of most browsers (Safari, Firefox) when I am logged in to wordpress, and all browsers that I have tested when I am logged off and the site has been made public (Chrome, Firefox and Safari).
      As a result, I have managed to identify the probable cause. It looks as though these browsers are refusing to render my sites compiled CSS file due to it being a HTTP URL rather than HTTPS.
      I have attempted to change this URL to HTTPS in my browser, however it brings back an ERROR: File not found page - https://www.shortfilmblog.com/wp-content/uploads/pagelines/compiled-css-core-1505847507.css
      What would you suggest in this regard? Would this be resolvable from your end?
      Happy to provide any further details required.
    • Borries
      By Borries+
      I know this is not an easy problem. Maybe there is a easy solution.
      I have tryed to uses the existing solution, that I have found in the forum
      I changed the colours of my nav (simple nav) and the hover effect (a. hover).
      I really tryed to highlight the active/used link in the nav but I cant figure it out.
      I want it to be black when active.
      Any help would be appreciated. Thanks.
      http://www.marcborries.de  nav link: "Sinn & Selbst" 
    • tuciudadenred
      By tuciudadenred+
      Hi everyone, what happens is that the web page metrosalarmas.com has a google tags which I have not attacked where I can look to remove those tags and be able to locate the correct ones.
    • Michael Kummer
      By Michael Kummer+
      Hi guys,
      every since Chrome introduce scroll anchoring (see chrome://flags) blog posts on my page start scroll automatically as soon as the user scrolls down a bit. It is super annoying and I don't know exactly what triggers the incompatibility with Chrome's latest feature that is supposed to improve usability.
      Since I don't know what causes it (Pagelines, or a Plugin), I would like to disable the feature using a CSS override that Google describes as follow:
      "Scroll anchoring aims to be the default mode of behavior when launched, so that users benefit from it even on legacy content. A CSS property overflow-anchor can disable scroll anchoring in part or all of a webpage (opt out), or exclude portions of the DOM from the anchor node selection algorithm. This property supports the following values when applied to an element E:
      overflow-anchor: auto (the default value) declares that the DOM subtree rooted at E is eligible to participate in the anchor node selection algorithm for any scrolling box created by E or an ancestor of E. overflow-anchor: none declares that the DOM subtree rooted at E is not eligible to participate in the anchor node selection algorithm for any scrolling box created by E or an ancestor of E." Do you guys happen to know how to use that property with the ROOT element so it applies to the whole page?
      Thanks
      Michael 
×