?
Solved

Need proper help with elseif statement Wordpress

Posted on 2011-10-20
5
Medium Priority
?
254 Views
Last Modified: 2012-05-12
Hello,
I've got a video and a slider appearing in an accordion, but only one should show up depending on what the user has entered in the edit page.
I know I need an elseif somewhere, but I'm not putting it in the right place So I'm getting the blank page. Could someone look over my code and tell me how I can get the video to show up if the ID has been entered or have the slider come up if the image and captions have been entered. It's video or slider. Can't have both.

<li class="behind-scenes">
            <h2>Behind the Scenes</h2>
						<div class="inner video">
             <?php
								$ytubeID = get_post_meta($post->ID, '_youtubeID', true);
								$vimID = get_post_meta($post->ID, '_vimeoID', true);
									if ($ytubeID || $vimID){
										if ($ytubeID){
											$ytube = 'http://www.youtube.com/v/'.$ytubeID.'?fs=1&hd=0';
											echo '<br />';
											echo '<object width="577" height="352">';
											echo '<param name="movie" value="'.$ytube.'"></param>';
											echo '<param name="allowFullScreen" value="true"></param>';
											echo '<param name="allowScriptAccess" value="always"></param>';
											echo '<embed src="'.$ytube.'" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="577" height="352">';
											echo '</embed>';
											echo '</object>';
											
										} elseif ($vimID){
											echo '<br />';
											echo '<iframe src="http://player.vimeo.com/video/'.$vimID.'?title=0" width="577" height="352" frameborder="0"></iframe>';
									} //end if yutbeID or vimIDthe_excerpt(); //excerpt added for information
								}
							?>
            </div> 
            
            <div id="slideshowCont">
							<ul>
							 <?php 
										if('' !== $data = get_post_meta($post->ID, 'image01', true)) {
											echo '<li><img src="';
    									echo  $data;
    									echo '" />';
    								} ?>
    								<?php 
										if('' !== $data = get_post_meta($post->ID, 'caption01', true)) {
											echo '<div><p>';
    									echo  $data;
    									echo '</p></div></li>';
    								} ?>
							<?php 
										if('' !== $data = get_post_meta($post->ID, 'image02', true)) {
											echo '<li><img src="';
    									echo  $data;
    									echo '" />';
    								} ?>
    								<?php 
										if('' !== $data = get_post_meta($post->ID, 'caption02', true)) {
											echo '<div><p>';
    									echo  $data;
    									echo '</p></div></li>';
    								} ?>
							 
							<?php 
										if('' !== $data = get_post_meta($post->ID, 'image03', true)) {
											echo '<li><img src="';
    									echo  $data;
    									echo '" />';
    								} ?>
    								<?php 
										if('' !== $data = get_post_meta($post->ID, 'caption03', true)) {
											echo '<div><p>';
    									echo  $data;
    									echo '</p></div></li>';
    								} ?>
							<?php 
										if('' !== $data = get_post_meta($post->ID, 'image04', true)) {
											echo '<li><img src="';
    									echo  $data;
    									echo '" />';
    								} ?>
    								<?php 
										if('' !== $data = get_post_meta($post->ID, 'caption04', true)) {
											echo '<div><p>';
    									echo  $data;
    									echo '</p></div></li>';
    								} ?>
							 
							</ul>
								<div id="sliderControls">
								<img src="<?php bloginfo('stylesheet_directory'); ?>/images/lastArrow.png" alt="last" title="last" id="last"/>
								<img src="<?php bloginfo('stylesheet_directory'); ?>/images/nextArrow.png" alt="next" title="next" id="next"/>
								</div>
							</div
          </li>

Open in new window


Thanks so much!
Sorry about the indents in the code.
0
Comment
Question by:Alicia St Rose
  • 2
  • 2
5 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 36999025
Please post a link to the URL that shows this issue in action, thanks.
0
 
LVL 3

Expert Comment

by:clamps
ID: 36999069
just put a print "if #1"; ... print "#2"; and so on in all your if clauses to see where it takes you, this way you will figure it out very easily by yourself.
cheers
0
 
LVL 3

Expert Comment

by:clamps
ID: 36999082
my guess is, neither ytubeID nor vimID are true...
if you don't know for sure, just put a print "something" behing

if ($ytubeID || $vimID){
 .....
} else {
print "something;
}
0
 
LVL 8

Accepted Solution

by:
Alicia St Rose earned 0 total points
ID: 37018953
I decided to not do
elseif

Open in new window

and just echo any input in the slider. This is a better option, providing more slider content.
Here's my code:

<li class="behind-scenes">
            <h2>Behind the Scenes</h2>
						
           
            
            <div id="slideshowCont">
							<ul>
								
							 <?php 
										if('' !== $data = get_post_meta($post->ID, 'image01', true)) {
											echo '<li><img src="';
    									echo  $data;
    									echo '" />';
    								} ?>
    								<?php 
										if('' !== $data = get_post_meta($post->ID, 'caption01', true)) {
											echo '<div><p>';
    									echo  $data;
    									echo '</p></div></li>';
    								} ?>
							<?php 
										if('' !== $data = get_post_meta($post->ID, 'image02', true)) {
											echo '<li><img src="';
    									echo  $data;
    									echo '" />';
    								} ?>
    								<?php 
										if('' !== $data = get_post_meta($post->ID, 'caption02', true)) {
											echo '<div><p>';
    									echo  $data;
    									echo '</p></div></li>';
    								} ?>
							 
							<?php 
										if('' !== $data = get_post_meta($post->ID, 'image03', true)) {
											echo '<li><img src="';
    									echo  $data;
    									echo '" />';
    								} ?>
    								<?php 
										if('' !== $data = get_post_meta($post->ID, 'caption03', true)) {
											echo '<div><p>';
    									echo  $data;
    									echo '</p></div></li>';
    								} ?>
							<?php 
										if('' !== $data = get_post_meta($post->ID, 'image04', true)) {
											echo '<li><img src="';
    									echo  $data;
    									echo '" />';
    								} ?>
    								<?php 
										if('' !== $data = get_post_meta($post->ID, 'caption04', true)) {
											echo '<div><p>';
    									echo  $data;
    									echo '</p></div></li>';
    								} ?>
							<?php 
							 			if('' !== $data = get_post_meta($post->ID, 'vimeo', true)) { ?>
								<li><iframe src="http://player.vimeo.com/video/<?php echo $data; ?>
								?title=0&amp;byline=0&amp;portrait=0" width='577' height='352' frameborder='0'" webkitAllowFullScreen allowFullScreen>></iframe></li>
								<?php } ?>
								
								<?php 
							 			if('' !== $data = get_post_meta($post->ID, 'youtube', true)) { ?>
								<li><iframe title="YouTube video player" width='577' height='352' src="http://www.youtube.com/embed/<?php echo $data; ?> frameborder='0' allowfullscreen"></iframe></li>
																<?php } ?>

Open in new window

                                               
                                          
0
 
LVL 8

Author Closing Comment

by:Alicia St Rose
ID: 37049213
Decided elseif wasn't the best option. Especially, since I couldn't get it to work.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month17 days, 10 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question