PHP display content based on day and timeframe - php

I need to display the ON AIR CONTENT every Friday at 9pm and then stop at 12am and revert back to the OFF AIR CONTENT. 
Below are the 2 sets of code that I manually change to make this possible. If I get the right code I can automate this.
Can anyone help me?
/* ON AIR CONTENT*/
function banner_rotator() {
if (is_home()) { ?>
<div id="rotator"><iframe width="630" height="386" src="http://www.ustream.tv/embed/8805257?v=3&wmode=direct?autoplay=true" scrolling="no" frameborder="0" style="border: 0px none transparent;"> </iframe> <?php if(function_exists('vslider')){ vslider('frontpage'); } ?></div>
<div class="main">
<!-- FIFTH EXAMPLE -->
<div class="view view-fifth">
<img src="../1.jpg" />
<div class="mask">
<h2>FULLY LOADED 2012</h2>
<p>This event has been cancelled.</p>
Details
</div>
</div>
<div class="view view-fifth">
<img src="../2.jpg" />
<div class="mask">
<h2>KAFINAL - FALLING IN LOVE</h2>
<p>"The feedback to Falling in Love has been tremendous all over. I am getting calls from people in Jamaica, the Caribbean and even in the States...</p>
Read More
</div>
</div>
</div>
<?php }
}
add_action('thesis_hook_before_content', 'banner_rotator');
_____________________________________________________________________________________
/* OFF AIR CONTENT */
function banner_rotator() {
if (is_home()) { ?>
<div id="rotator"> <?php if(function_exists('vslider')){ vslider('frontpage'); } ?></div>
<div class="main">
<!-- FIFTH EXAMPLE -->
<div class="view view-fifth">
<img src="../1.jpg" alt="FULLY LOADED 2012" title="FULLY LOADED 2012" />
<div class="mask">
<h2>FULLY LOADED 2012</h2>
<p>This event has been cancelled.</p>
Details
</div>
</div>
<div class="view view-fifth">
<img src="../2.jpg" alt="KAFINAL - FALLING IN LOVE" title="FULLY LOADED 2012" />
<div class="mask">
<h2>KAFINAL - FALLING IN LOVE</h2>
<p>"The feedback to Falling in Love has been tremendous all over. I am getting calls from people in Jamaica, the Caribbean and even in the States...</p>
Read More
</div>
</div>
</div>
<?php }
}
add_action('thesis_hook_before_content', 'banner_rotator');

The PHP date("G") function will give you the time in 24 hour format as a string. You may then test that and make whatever decisions you would like.

Related

Email content exceeds width of screen

I have a php Mailer email in which I am styling the html email. Everything is correct except my content within #email-header exceeds the width of the screen. I am not sure why because I set the max-width to 600px.
Does anyone see anything I am doing wrong which would be causing this?
$mail2->Body = '
<body>
<div id="header-background" style="background:#16597B;width:100%;max-width:100%;height:auto;">
<div id="email-header" style="width:600px;max-width:600px;height:auto;margin:auto;display:block;padding:20px 8px;">
<div id="logo"><img src="" style="width:200px;height:auto;text-align:center" alt=""></div>
<div style="clear:both;"></div>
<div id="email-to" style="color:#FFF;font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-weight:bold;font-size: 2em;margin-top:35px;">Hi '.$consult_name.',</div>
<div id="email-header-description" style="font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:1.3em;color:#d0dde4;margin-top:45px;">
<p style="font-size:1.3em;">Thanks for wanting to work with us!</p>
<p>We received your consultation inquiry. Here shortly your information will be reviewed and we will be in touch with you as soon as possible to schedule your consultation.</p><br>
<p>Thanks again!</p><br>
</div>
</div>
</div>
</div>
</body>
';
The problem is that you have a fixed width of 600px in addition to your max-width of 600px. Simply removing the fixed width should fix your word-wrap problem.
Note that 600px is a rather high breakpoint for mobile phones, as many phones have a display below this. I'd recommend 300px to cover most devices.
Also note that you have an additional closing </div>, which may cause some clients to play up a little.
Here's updated code that fixes both of these issues:
$mail2->Body = '
<body>
<div id="header-background" style="background:#16597B;width:100%;max-width:100%;height:auto;">
<div id="email-header" style="max-width:600px;height:auto;margin:auto;display:block;padding:20px 8px;">
<div id="logo">
<img src="http://placehold.it/100" style="width:200px;height:auto;text-align:center" alt="">
</div>
<div style="clear:both;"></div>
<div id="email-to" style="color:#FFF;font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-weight:bold;font-size: 2em;margin-top:35px;">Hi '.$consult_name.',</div>
<div id="email-header-description" style="font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:1.3em;color:#d0dde4;margin-top:45px;">
<p style="font-size:1.3em;">Thanks for wanting to work with us!</p>
<p>We received your consultation inquiry. Here shortly your information will be reviewed and we will be in touch with you as soon as possible to schedule your consultation.</p>
<br>
<p>Thanks again!</p>
<br>
</div>
</div>
</div>
</body>
';
Hope this helps! :)

Kirby snippet shows only 10 subpages

I'm working on this (NSFW), I created 12 subpages but only 10 are showing in the list.
I'm not using any limit() or pagination() in the snippet nor in the panel config, I can't find where this limit is regulated. My guess is a numbering issue, because if in the panel I drag up the 11th subpage up, anything below will not be displayed.
Any clue?
php:
<section id="entries">
<ul>
<li>
<div class="line asger">
<div class="text">00</div>
<div class="text bold">Asger Carlsen</div>
</div>
</li>
<?php $n = 1; foreach($pages->children()->visible()->sortBy('date', 'asc') as $entries): ?>
<li>
<div class="line">
<div class="text">0<?php echo $n++; ?></div>
<div class="table"><div class="text bold"><?php echo kirbytext($entries->title()) ?></div></div>
<div class="text"><?php echo kirbytext($entries->kind()) ?></div>
</div>
<div class="description hidden">
<?php echo kirbytext($entries->description()) ?>
</div>
<div class="left-half">
<img class="images hidden" src="<?php echo $entries->images()->first()->url() ?>" alt="<?php echo html($entries->title()) ?>" />
</div>
</li>
<?php endforeach ?>
</ul>
</section>
Folder structure: https://www.dropbox.com/s/8gigspwup0kwqei/Screenshot%202014-09-03%2015.39.51.png?dl=0
Your folder-structure is defiantly correct. You only could try to rename 04-2001 to something like 04-foo2001 but i don`t think that this causes your issue.
I had some quite similar behavior once. It was caused by image-metadata txt's that had the same name like the page-content txt's. So maybe it would be helpful if you show us your complete folder-structure including the files/filenames.
Next idea: Are you sure you have no invalid markdown in your txt's?
PS: This should be a comment, but i’m at 49 reputation, so i’m not allowed to comment ;) cheers!
It was probably a combination of .txt name conflict plus a missing image from a page.

Php to auto populate grids

I have the following html code:
<div class="media row-fluid">
<div class="span3">
<div class="widget">
<div class="well">
<div class="view">
<img src="img/demo/media/1.png" alt="" />
</div>
<div class="item-info">
Title 1
<p>Info.</p>
<p class="item-buttons">
<i class="icon-pencil"></i>
<i class="icon-trash"></i>
</p>
</div>
</div>
</div>
<div class="widget">
<div class="well">
<div class="view">
<img src="img/demo/media/2.png" alt="" />
</div>
<div class="item-info">
This is another title
<p>Some info and details go here.</p>
<p class="item-buttons">
<i class="icon-pencil"></i>
<i class="icon-trash"></i>
</p>
</div>
</div>
</div>
</div>
Which basically alternates between a span class with the widget class, and then the widget class without the span3 class.
What I wanted to know was if there was a way to have php "echo" or populate the details for and details under the "item-info" class. Would I need to use a foreach statement to get this done? I would be storing the information in a mysql database, and while I can get it to fill in the info one by one (repeatedly entering the and echoing out each image and item title) it's not practical when the content needed to be displayed is over 15 different items. I'm not well versed in foreach statements so I could definitely use some help on it.
If someone could help me perhaps structure a php script so that it can automatically output the html based on the number individual items in the database, that'd be greatly appreciated!
I'm wondering if the html + php (not including the foreach) would look like this:
<div class="span3">
<div class="widget">
<div class="well">
<div class="view">
<img src="img/<? $file ?>" alt="" />
</div>
<div class="item-info">
<?$title?>
<p>Info.</p>
<p class="item-buttons">
<i class="icon-pencil"></i>
<i class="icon-trash"></i>
</p>
</div>
</div>
</div>
EDIT:
I wanted to add some more information. The items populated would be based on a type of subscription - which will be managed by a group id.
I was initially going to use <? (if $_SESSION['group_id']==1)>
echo <div class="item-info">
$title
<p>$info</p>
</div>
so that only the subscribed items would populate. But, I would need it to iterate through all the items for group1 table and list it. Currently I know that I can do
<? (if $_SESSION['group_id']==1)
while ($row=mysql_fetch_assoc($sqlItem))
{
$itemInfo = $row['info'];
$image = $row['image'];
$title = $row['title'];
$url = $row['url'];
};
>
$sqlItem for now can only be assigned one thing (manually - as in: $sqlItem = '123'), unless I iterate through which is what I'm trying to figure out.
Just read that 'mysql_fetch_assoc' is being depreciated with 5.5, here is the new way and looks better, easier I think.. Hope this helps, was updated today.
I hope this helps http://php.net/manual/en/mysqli-stmt.fetch.php
replace the printf with echo '//then your html stuff
This will iterate through the rows in your database until their are no more matching records.
shouldn't a while be enough? It depends on the structure of your database and website (we didn't need so much HTML I think. Some more PHP maybe). Hope this helps.

Generate JQuery code inside a PHP foreach loop

UPDATE
for JLRiche
html structure below (here is the structure for the entire div id=content_body_right):
<div id="content_body_right">
<p class="user_text">Tim Flanagan</p><p class="date_text">02-06-2013 # 12:00PM</p>
<p class="message_text">Playin Augusta today. What a beautiful course!</p>
<div id="activity_image">
<img src="images/activities/1/actimg.jpg" width="435" />
</div>
<div id="tips">
<div id="tip_cap_left">
<a href="dashboard.php?captip=tipyourcap" title="Tip Your Cap" ></a>
</div>
<div id="tip_cap_right">
<p class="tips_right">12 Tips of the Cap</p>
</div>
</div>
<p class="comments_label">
4 Comments
see all
collapse
</p>
<div id="comment1">
<div id="comment_user_img">
<img src="images/defaultuserimg.jpg" width="30" height="30" />
</div>
<div id="comment_user">
<p class="user_text_comment">Tim Flanagan</p><p class="date_text_comment">02-06-2013 # 12:00PM</p>
<p class="message_text_comment">Nice jealous of you bro.</p>
</div>
</div>
<div class="comment2" style="display:none; clear:both; margin:0px; overflow:auto">
<div id="comment2_sub">
<div id="comment_user_img">
<img src="images/defaultuserimg.jpg" width="30" height="30" />
</div>
<div id="comment_user">
<p class="user_text_comment">Tim Flanagan</p><p class="date_text_comment">02-06-2013 # 12:00PM</p>
<p class="message_text_comment">Nice jealous of you bro.</p>
</div>
</div>
<div id="comment2_sub">
<div id="comment_user_img">
<img src="images/defaultuserimg.jpg" width="30" height="30" />
</div>
<div id="comment_user">
<p class="user_text_comment">Tim Flanagan</p><p class="date_text_comment">02-06-2013 # 12:00PM</p>
<p class="message_text_comment">Nice jealous of you bro.</p>
</div>
</div>
<div id="comment2_sub">
<div id="comment_user_img">
<img src="images/defaultuserimg.jpg" width="30" height="30" />
</div>
<div id="comment_user">
<p class="user_text_comment">Tim Flanagan</p><p class="date_text_comment">02-06-2013 # 12:00PM</p>
<p class="message_text_comment">Nice jealous of you bro.</p>
</div>
</div>
</div>
</div>
Let me know if you need more structure, because there is alot above and below it. Hope this helps.
I really appreciate your help!
END UPDATE
Good Evening All,
I need to dynamically create X amount of jquery scripts foreach of the X amount of db results. X meaning the the number will vary. It is sort of a forum type thing where you see the original post with one reply showing and you would click see all or collapse all to view or collapse the rest. I am incrementing my html elements inside a foreach loop with the typical $i variable so I need to output jquery click functions for each as well.
The code I need PHP to create is below:
$jquery .= "$('#see_all$i').click(function () {
$('#comment2_$i').slideDown('fast');
$('#collapse$i').css('display', 'inline-block');
$('#see_all$i').css('display', 'none');
return false;
});
$('#collapse$i').click(function () {
$('#comment2_$i').slideUp('fast');
$('#collapse$i').css('display', 'none');
$('#see_all$i').css('display', 'inline-block');
return false;
})";
Any help would and always will be much appreciated!
Thanks
Generating multiple, slightly different copies of the same jQuery code is not a very good design, IMHO. You should write your jQuery code in a way that it only needs to be in your page once, like:
$('.see_all').click(function(){
var thisItem = $(this);
thisItem.parent().find('.comment').slideDown('fast');
thisItem.parent().find('.collapse').css('display','inline-block');
thisItem.css('display','none');
return false;
});
$('.collapse').click(function(){
var thisItem = $(this);
thisItem.parent().find('.comment').slideUp('fast');
thisItem.css('display','none');
thisItem.parent().find('.see_all').css('display','inline-block');
return false;
})";
Of course, this would also involve adding collapse, see_all, and comment classes to the relevant HTML elements.
html :
<div class="seeall" data-elid="1">...</div>
...
<div class="collapse" data-elid="1">...</div>
...
js :
var $bdy=$(document.body)
$bdy.on("click",".seeall",function(e) {
var el=$(this).css('display','none').data("elid");
$('#comment2_'+el).slideDown('fast');
$('.collapse[data-elid="'+el+'"]').css('display','inline-block');
})
.on("click",".collapse", function(e) {
//same same
});

Wordpress as a CMS, calling content Issue

So I am working on my first wordpress site...
I am having a go at converting http://www.benjaminpotter.org/fleet/
to wordpress > http://www.benjaminpotter.org/test/
So there are already a few issues, but one of the things is that I am wanting to call content into the "about us" section on the index page via wordpress to act as a CMS.
This is an image of the back end:
nevertheless it ends up with no content in that section:
this is most likely because I need to put in a bit of code into the page of the website.
This is the current code for that page, and I have commented where I want to call the content mannaged bit... thanks for the help!
<? /* Template Name: Home Page
*/ ?>
<?php get_header(); ?>
<div id="tagline"></div>
<div id="sliderbox">
<img src="<?php bloginfo('template_url'); ?>/images/index/slider/slider_1.jpg" width="1000" height="466" alt="Don't settle for less" />
<img src="<?php bloginfo('template_url'); ?>/images/index/slider/slider_2.jpg" width="1000" height="466" alt="Don't settle for less" />
<img src="<?php bloginfo('template_url'); ?>/images/index/slider/slider_3.jpg" width="1000" height="466" alt="Don't settle for less" />
<img src="<?php bloginfo('template_url'); ?>/images/index/slider/slider_4.jpg" width="1000" height="466" alt="Don't settle for less" />
</div>
<a id="arrow2" class="arrow"></a>
<a id="arrow1" class="arrow"></a>
<a href="order.php" id="car_logo_slider" onmouseover="tooltip.show('');" onmouseout="tooltip.hide();">
<img src="<?php bloginfo('template_url'); ?>/images/index/car_slider/cars1.jpg" width="1001" height="86" alt="cars" />
<img src="<?php bloginfo('template_url'); ?>/images/index/car_slider/cars2.jpg" width="1001" height="86" alt="cars" />
<img src="<?php bloginfo('template_url'); ?>/images/index/car_slider/cars3.jpg" width="1001" height="86" alt="cars" />
</a>
<div id="wrapper-contunue">
<div id="mission_vision_header"></div>
<? include('inc/quickcontact.html'); ?>
<div id="mission_vision_text">
<!-- THE CONTENT MANAGED BIT! -->
<!-- THE CONTENT MANAGED BIT! -->
<!-- THE CONTENT MANAGED BIT! -->
<!-- THE CONTENT MANAGED BIT! -->
<!-- THE CONTENT MANAGED BIT! -->
</div>
<div style="margin-top:450px;" class="seperator"></div>
<div id="our_process" class="highlighed_div">
<div id="our_process_header"></div>
<div id="initial_text_our_process">
Here at Fleet Avenue, we have a simple and straight forward process towards acquiring our cars for you. This four step process is fast and effective, consisting of the following steps:
</div>
<div id="our_process_stages_graphic"></div>
<div id="explanatiory_text_our_process">
<div id="process_inquire">
<a id="inquire_button" href="order.php"></a>
</div>
</div> <?php get_footer(); ?>
<?php echo get_content(); ?>
Or
<?php
global $post;
echo $post->post_content;
?>
i believe you need to wrap you call to the_content() in the Wordpress loop
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_content();
} // end while
} // end if
?>
this is a very basic example if you make other calls later you will need to reset the query call after this one.
more info here: https://codex.wordpress.org/The_Loop

Categories