Display text on webpage from list depending on date - php

I'm not professional developer, but I help to manage the IT for a group of churches in the UK. I thought this might be the place to ask for help.
They have a website, which runs wordpress. They also have a monthly prayer diary. There is a list, and each day, members pray for something or someone specific.
I was wondering if there was a way of displaying the day's prayer using PHP/HTML, on the site, from a list of prayers that is located on the server. For example, on 1st July, it might be 'We pray for the local schools', so somewhere on the site, on the 1st July would be the text 'Today we pray for the local schools'. This would automatically change to something like 'we pray for our local firefighters' on the 2nd of July, depending on what is on the list.
This would preferably be done by easily uploading a csv file(?) to wordpress/the web server, and the site would automatically find and display the prayer associated with today's date (server-side time) from the file???
I'm running wordpress on Windows IIS, with PHP of course.
I would be really grateful if someone could help.
Thanks

You could use a 'quote of the day' plugin. There are a number of them available, you just need to find one that allows you to upload the content.
Here's a search to start you off: https://www.google.com/search?client=firefox-b-d&q=wordpress+plugin+quote+of+the+day
The Flexi Quote Rotator on this page looks promising: https://hostingreviewbox.com/10-awesome-free-quote-of-the-day-wordpress-plugins/

Related

Show static block content for particular dates and times in magento 1.8

Hi we are planning to create a whole weeks worth of sales leading up to Black Friday. Usually when we have a sale I stay up until midnight and switch all the content on the site then change it back at midnight the next night.
For this week-long sale I would like to create a static block for each day in advance and then somehow make our homepage content switch between the blocks on midnight of each night. I am not sure of the best way to approach this.
I want to avoid making one big page and switching the content using JS as I don't want the links to each sale visible in the source code for any clever shoppers!
Any help will be appreciated.
Thanks,
Glynn

How to make featured image change automatically based on current time

I'm customising a wordpress site with a static front page. I'm using a responsive/dynamic theme.
What I want to do is make it so that the featured image that is loaded on the front page will be different based on a time. For example: Say someone goes to my website at 6pm, I would want the featured image on the front page to show a picture of the night sky. However, if someone visits my site before 6pm (and as early as say 5am), then the featured image should show a picture of the day sky.
Iv'e looked everywhere for a plugin to do this for me but one does not seem to exist. Iv'e also googled this endlessly and could not find specific solutions but I have been able to find sources to get me started.
Adding featured image from external source via php and sql:
http://www.wpexplorer.com/wordpress-featured-image-url/
(it would be easier to just use and UPDATE statement and change the image url in the database)
Getting time in given timezone:
Get current date, given a timezone in PHP?
I could have used a lot of the code from the links provided to achieve what I want but I ran into a PROBLEM. I CANNOT find the image url of the featured image in the wordpress database. I've looked in both _postmeta and _posts with no luck. Instead it just shows the image urls of the images that came with the theme originally but have since been changed. This could possibly have something to do with the fact that I've been using the Jetpack plugin (photon) to load my images from wordpress.com servers but I have turned the feature off and still can't find the image url in the database.
As I am not a pro in php and sql it would be great to be pointed in the right direction or even better if someone could come up with a solution. I know it's not an easy implementation but definitely worthwhile as solutions cannot be found elsewhere.
This can easily be done with javascript..
Here is a quick example I did:
https://jsfiddle.net/p2snuf1a/
var date = new Date();
var hours = date.getHours();
var sunset_img= "http://at-cdn-s01.audiotool.com/2014/06/03/documents/85NwUJbwC0Gx0rbiKePSWWcKUqhmdP/0/cover256x256-46428e19514b49058125b21b8107c2eb.jpg";
var night_img = "https://pbs.twimg.com/profile_images/2973095145/47f74748e0c6240db5e0b3034af6da16.jpeg";
if(hours > 18){
document.getElementById('feature_img').setAttribute('src', night_img);
}
else{
document.getElementById('feature_img').setAttribute('src', sunset_img);
}
Basically, it gets the current hour, sets some variables to the image links (these can be locally stored images too). Then it checks if the hours is greater or less than a certain time, so 18 is 6pm.
You can add more 'else if()' options for other time/image combinations.
If you have your images located in your css, you can use the '.sytle' instead of .setAttribute
Well this is a preety simple task, but i can see one issue with it. PHP will be using it's own server's time to calculate day and night. So if your server is in New york and some one is surfing your website from INDIA, it will show the image depending on the time in NEW YORK. So to achieve the user's local time you will either have to use javascript or use a geo locating api that will show the exact time of the given location. Here is an example.
http://api.geonames.org/timezone?lat=47.01&lng=10.2&username=demo
For now lets just suppose you want to change the image depending on the server time. So as you only have 2 images for day and night, hardcoding it should not be an issue. (If you want to have custom fields, can look into "Advanced custom fields" plugin, it is a brilliant plugin to add custom fields in your posts).
I haven't tested this code, but it should work.
date_default_timezone_set('America/Chicago');
$am_pm = date('a');
if($am_pm == 'am'){?>
<img src="<?php echo get_template_directory();?>/images/am.png" alt="Good Morning">
<?php }elseif($am_pm == 'pm'){?>
<img src="<?php echo get_template_directory();?>/images/pm.png" alt="Good Evening">
<?php }?>

php sessions not passing on iframe safari

I have created a booking system where users select the date (or dates they want to book on an availability chart, click Book, then go to the next page "Booking Page" to fill in their details. When they tick the date on the availability page the date or dates are put into a session that is picked up on the next page(Booking page).
People can add this system into a page on their own websites using an iframe. This worked really well, but recently people using safari (mac,ipad) select the date, click Book, but when they they are taken to the booking page are told that no day has been selected. I can't understand why when I test it on my pc using safari and my ipad it works fine. But this has now been reported by several people that they can't book a date.
I have read that this is something that safari has done for security reasons.
I have tried adding this:
header('P3P: CP="CAO PSA OUR NOI ADM DEV COM NAV OUR STP"');
Can anyone please advise on how I can overcome this problem, preferably without having to ask all the people using it to add code to the page.
Many thanks

Best way to create a kiosk app displaying a movie and a few contact links?

I'm trying to create a web based welcome display for a building entrance. The project would include:
1) A wmv movie play constantly on the digital display until some visitors touch the screen (this can be played either locally or on the internet, but it has to be able to go to number 2 when visitors touch the screen)
2) A couple of buttons with department names show up for visitors to choose who they are here to see
3) After the visitor touch on one button, an email is sent to the department
4) Thank you page, the site should go back to the number 1) again
My experience is html, css, php, javascript, and some Flash, but I'm open to learn new skills. Can someone please suggest some good ways to build this site? Is there any tutorials or good sites I can learn from, that would be a bonus.
Thanks very much.
Sam :)
Edit:
Thanks very much Vigrond and Lloyd! You guys' answers are equally helpful, so I'll use html5 and javascript.
I have a couple of further questions, I hope you guys or someone can help me. (Any part of questions' help is appreciated)
Since this is going to be a kiosk, the same movie is going to be played constantly, everytime after the customer has contacted us, the 'thank you' page is going to show briefly and go back to the first movie page. My question is how can I not let the movie load again and again everytime when there is a customer? Because the local data space for the display is going to be limited.
I've been thinking if I just create one page for the whole process and use a javascript slide to make each page as a div, so the movie div is going to be hiden so it doesn't need to be reloaded again, would that fix number 1) data space concern?
I'm thinking of using a horizontal slide like http://www.queness.com/post/356/create-a-vertical-horizontal-and-diagonal-sliding-content-website-with-jquery How can I make the last div (thank you) to show about 5 secs and go to the first div (movie) again?
Thanks very much! :)
This can be purely done using html5/javascript (+php for the email sending). Google Chrome also has a -kiosk mode, that will enable fullscreen.
I would probably use HTML5 video, along with something like the jQuery cycle plugin. On the video onclick handler, I would just cycle() to the next 'slide'. You can put in effects such as fadein, fadeout, slide, etc.
If you wanna get fancy, a mobile framework such as jQuery mobile or Sencha mobile may be right up your ally as well, (with aesthetic familiar interfaces and cool transitions)
beside some backend PHP to send email, this trivial app could be built using plain old HTML5, CSS and Javascript.. I wouldn't bloat it with jQuery or jQuery plug-ins unless necessary..
I don't recommend using WMV content, though - this proprietary format is not supported by any of the main browsers.. To ensure maximum browser support, encode you media using an open format like WebM:
http://www.webmproject.org/

Openx Ad Delivery Issues

My System
Apache 2.2.9
PHP 5.2.9
MySQL client version: 5.1.28-rc
Openx v2.8.5
I am using the Javascript single page call to serve my ads. I am running an in house CMS where everything is processed through a template.php file.
My Issue
The success of an ad being served seems to be very hit and miss. The placement or type of the ad does not seem to matter. For some reason, the loading of the ads is very spotty. Each page serves an average of 3 ads. Sometimes none show up, sometimes 2, sometimes 1. There does not seem to be any consistency in the problem occurring. The problem seems to have worsened since I updated to the most recent version and started using Single Page Call.
I have checked the source. All Javascript script is in place, but the ad content is not generated under the script where it should be. The space where the ad should be is just empty.
No Javascript errors are generated.
Any help will be greatly appreciated.
For me, this happened when the campaigns assigned to the zone were all contract and there was no Remnants assigned. OpenX basically had no banners with impressions left to display.
Also, another time t his happened was with their implementation of Single Page Call. OpenX pre-loads all zones you have put into the array on every page, regardless of if they are displayed or not. So if you have a lot of zones, the ones near the end of the array can not get any ads because the ones above it take all the ads with impressions.
If you have a CMS with a lot of advertising zones, you're going to have to dynamically control the Javascript array to only load the zones needed for display on that specific page. I have a solution for Joomla if you need more details.

Categories