• Resolved mcfester

    (@mcfester)


    Hi, I currently use the plugin to add videos to galleries by adding the video code into a custom field text area for each gallery, this works great untill I want to adjust size or other setting on the video as I have to manually edit each gallery, and I have a lot of galleries.
    What I’m trying to do is add the video code to gallery.php and then use a custom field to show it on selected galleries.
    I’ve been trying this without success so far:

    <?php if (condition): ?>
    
    html code to run if condition is true
    
    <?php else: ?>
    
    html code to run if condition is false
    
    <?php endif ?>

    But I dont know what to do for the condition.
    So my custom field is nggcf_get_gallery_field($gallery->ID, "mp4") and it is a drop down selection with just one option TRUE, I’m hoping that if the condition is not met TRUE it wont show, that way I don’t need to select false on galleries with no videos, this works with other custom fields I’ve done by just leaving them empty.
    But how do I set the condition to show TRUE so it shows the video html?

    https://www.ads-software.com/plugins/nextgen-gallery-custom-fields/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author shauno

    (@shauno)

    Hi mcfester

    If the value is literally “TRUE”, than this will do what you want:

    <?php if(nggcf_get_gallery_field($gallery->ID, "mp4") == "TRUE"): ?>
    	//true condition
    <?php else: ?>
    	//false condition
    <?php endif; ?>
    Thread Starter mcfester

    (@mcfester)

    Hi, thanks, I’ve also just this minute found a solution nearly the same as yours, I was having problems with the brackets in wrong places etc, not being a coder I’ve been up all night playing with this simple bit of code.

    <?php if (nggcf_get_gallery_field($gallery->ID, "Include Video") == 'Yes') { ?>
    	<!-- Video -->
    	<div class="video">
    		My video code here!
    	</div>
    <?php } ?>

    My first bit of coding, I’m impressed lol

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need help with php code to add videos’ is closed to new replies.