Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
So I have been working on this website for some time now and had just finished making an image gallery with a modal. Now I am working on a video gallery with modal, as well as an iframe gallery with a modal. I am using shortcodes to make it easier to embed youtube and vimeo videos onto the website. For the video gallery, I wish to have a custom image for the thumbnails, then when it is clicked I want it to open a modal up to the video. But so far, when I try to do a clonable or a repeatable page, to make a gallery, I get a problem that it replaces the shortcode with the images code. As the code stands down below, it can have one image and one embedded video, and run fine, besides the video continuing to play after the modal is closed.

Html
Code: Select all
?php require_once( '../couch/cms.php' ); ?>
<cms:template title='Film Gallery'>
    <cms:editable
                  name='film_poster'
                  label='Poster'
                  desc="Place Film Posters Here"
                  show_preview='1'
                  width='500'
                  type='image'
                  />
        <cms:editable
                  name='film_content'
                  label='Films'
                  desc="Place Video Url's Here"
                  type='textarea'
                  no_xss_check='1'
    />
</cms:template>
<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href='../../css/style.css'>
        <script src="/js/jquery-3.3.1.js"></script>
        <script src="/js/bootstrap.js"></script>
        <script src="/js/modal_02.js"></script>
    </head>
    <body class="film-bg">
        <nav>
            <div id="navbar">
                <ul>
                    <li>
                        <a class="uno" href="../../index.php">Home</a>
                    </li>
                    <li class="dropdown">
                        <a class="dropbtn" href="../../works.php">Work</a>
                        <div class="dropdown-content">
                            <a href="../../works/3d.php">3D</a>
                            <a href="../../works/animation.php">Animation</a>
                            <a href="../../works/art.php">Art</a>
                            <a href="../../work0s/film.php">Film</a>
                        </div>
                    </li>
                    <li>
                        <a class="tres" href="../../news.php">News</a>
                    </li>
                     <li>
                        <a class="quatro" href="../../contact.php">Contact</a>
                    </li>
                </ul>
            </div>
        </nav>
            <div id="container">
                <div class="film-content">
                <cms:pages masterpage='works/film.php'
                           paginate='1'
                           limit='8'
                           >
                        <a href="#" class="film-pop">
                            <img class="img-size" src="<cms:show film_poster />" >
                            <div class="hr clearfix">&nbsp;</div>
                        </a>
                    <div class="hr clearfix">&nbsp;</div>
                    <cms:paginator id="page"/>
                    </cms:pages>
                    </div>
            <footer class="clrfix">
                <p class="wrap">##########</p>
            </footer>
            </div>
        <div class="modal fade" id="filmmodal" tabindex="-1" role="dialog" hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                     <button type="button" class="close" data-dismiss="modal">x</button>
                                </div>
                                <div class="modal-body">
                                    <cms:do_shortcodes><span class="filmpreview"><cms:show film_content /></span></cms:do_shortcodes>
                                </div>   
                            </div>
                        </div>
                    </div>
    </body>
</html>
<?php COUCH::invoke(); ?>


JS
Code: Select all
$(function () {
    $('.film-pop').on('click', function () {
        $('.filmpreview').attr('src',
    $(this).find('img').attr('src'));
        $('#filmmodal').modal('show');
    });
});


It would be much appreciated if I could get some pointers sooner rather than later. Thank you, and I apologize for the messy coding.
Hi,

A problem that immediately stands out is that you are using <cms:show film_content /> outside <cms:pages> loop -
Code: Select all
<cms:do_shortcodes><span class="filmpreview"><cms:show film_content /></span></cms:do_shortcodes>

This will cause 'film_content' to show only the value from the page being currently visited (and nothing in a list-view).

Anyway, the recommended way of using Couch is to begin with a working static (only HTML/JS/CSS) design and then retrofit Couch tags in it. Since the design was working to begin with, it is easy to see if our Couch code is correct by comparing the static HTML with the generated one.

Therefore, I request you to begin with a design with at least two videos where you are sure that everything is working as you desire. Your quest then would be to isolate only one set of the elements used to display a video properly and wrap <cms:pages> around it to dynamically generate HTML for multiple videos.

Please try that. If you run into any trouble, feel free to provide us the working static design and the problem Couchified version of it.

Thanks.
Hi again, I've fixed all the problems that I was having and everything is now working without a hitch. However, I may be getting a little overzealous, but I want to add a text description to the modal gallery when it opens the modal. This works but not in the way I want. I want the descriptions to show up on the film PHP, but they only show up on the inaccessible HTML files, do you have any suggestions? Here's the updated code.


PHP
Code: Select all
<?php require_once( '../couch/cms.php' ); ?>
    <cms:template title='Film Gallery' clonable='1'>
        <cms:editable
                      name='fg_image'
                      label='Poster'
                      desc='Post Poster Here'
                      show_preview='1'
                      type="image"
                      />
        <cms:editable
                      name='fg_link'
                      label='Films'
                      desc='Post Embeded Film Links Here'
                      type="text"
                      />
        <cms:editable
                      name='fg_desc'
                      label='Film Description'
                      desc='Put Brief Description Here'
                      type="richtext"
                      />
    </cms:template>

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href='../../css/style.css'>
        <script src="/js/jquery-3.3.1.js"></script>
        <script src="/js/bootstrap.js"></script>
        <script src="/js/modal_02.js"></script>
    </head>
    <body class="film-bg">
        <nav>
            <div id="navbar">
                <ul>
                    <li>
                        <a class="uno" href="../../index.php">Home</a>
                    </li>
                    <li class="dropdown">
                        <a class="dropbtn" href="../../works.php">Work</a>
                        <div class="dropdown-content">
                            <a href="../../works/3d.php">3D</a>
                            <a href="../../works/animation.php">Animation</a>
                            <a href="../../works/art.php">Art</a>
                            <a href="../../work0s/film.php">Film</a>
                        </div>
                    </li>
                    <li>
                        <a class="tres" href="../../news.php">News</a>
                    </li>
                     <li>
                        <a class="quatro" href="../../contact.php">Contact</a>
                    </li>
                </ul>
            </div>
        </nav>
            <div id="container">
                <div class="film-content">
                    <cms:pages masterpage='works/film.php'
                               paginate='1'
                               limit='9'
                               >
                <a href="#" class="bmd-modalButton" data-toggle="modal" data-bmdSrc="<cms:show fg_link />" data-bmdWidth="640" bmdHeight="480" data-target="#filmModal" data-bmdVideoFullscreen="true">
                    <img class="img-size" src="<cms:show fg_image />">
                    </a>
                    <cms:paginator id="page"/>
                    </cms:pages>
                    </div>
            <footer class="clrfix">
                <p class="wrap">####################</p>
            </footer>
            </div>
            <div class="modal fade" id="filmModal" tabindex="-1" role="dialog" aria-labelledby="filmModalLabel" hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content bmd-modalContent">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal"><span>x</span></button>
                            </div>
                            <div class="modal-body">
                                <div class="embed-responsive embed-repsonsive-16by9">
                                    <iframe class="embed-responsive-item" frameborder="0"></iframe>
                                    <p><cms:show fg_desc /></p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
    </body>
</html>
<?php COUCH::invoke(); ?>


JS
Code: Select all
(function($) {
   
    $.fn.bmdIframe = function( options ) {
        var self = this;
        var settings = $.extend({
            classBtn: '.bmd-modalButton',
            defaultW: 640,
            defaultH: 360
        }, options );
     
        $(settings.classBtn).on('click', function(e) {
          var allowFullscreen = $(this).attr('data-bmdVideoFullscreen') || false;
         
          var dataVideo = {
            'src': $(this).attr('data-bmdSrc'),
            'height': $(this).attr('data-bmdHeight') || settings.defaultH,
            'width': $(this).attr('data-bmdWidth') || settings.defaultW
          };
         
          if ( allowFullscreen ) dataVideo.allowfullscreen = "";
         
          // stampiamo i nostri dati nell'iframe
          $(self).find("iframe").attr(dataVideo);
        });
     
        // se si chiude la modale resettiamo i dati dell'iframe per impedire ad un video di continuare a riprodursi anche quando la modale è chiusa
        this.on('hidden.bs.modal', function(){
          $(this).find('iframe').html("").attr("src", "");
        });
     
        return this;
    };
 
})(jQuery);




jQuery(document).ready(function(){
  jQuery("#filmModal").bmdIframe();
});


It's not a huge deal to get working immediately, but it would be a nice touch to have it working.
3 posts Page 1 of 1