We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50485
    • 56 Posts
    Hi, wonder if anyone can help,

    I am putting a static site in MODX where I had been using bxslider and it was working fine. However, I cannot seem to get it working in MODX and wonder if anyone could see what I am doing wrong?

    In the head of my template I refer to the slider:

    <!-- jQuery library (served from Google) -->
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <!-- bxSlider Javascript file -->
    <script src="/assets/js/bxslider/jquery.bxslider.min.js"></script>
    <!-- bxSlider CSS file -->
    <link href="/assets/css/bxslider/jquery.bxslider.css" rel="stylesheet" />
    <script>
    $(document).ready(function(){
      $('.bxslider').bxslider();
    });
    </script>


    Whilst in the body I refer to the slider and images to go in it:

    <div id="carousel-container">

    <ul class="bxslider">
    <li><img src="/assets/images/test1.png" alt="image name" /></li>
    <li><img src="/assets/images/test2.png" alt="image name" /></li>
    <li><img src="/assets/images/test3.png" alt="image name" /></li>
    </ul>

    </div><!--Carousel container ends-->


    The images appear but not in the slider as they do on the static site.

    Any advice much appreciated!

    Thanks, Su
      • 9995
      • 1,613 Posts
      Thats weird, I use bxslider allot. Don't see anything wrong.
      Do you have base_url in the head? Is the js / css loaded?

      <script>
      	$(document).ready(function(){
      		$('.bxslider').bxSlider({
      			mode: 'fade',  // fade, horizontal, vertical
      			speed: 500,
      			randomStart: false,
      			infiniteLoop: true,
      			useCSS: true,
      			touchEnabled: true,
      			pager: false,
      			controls: false,
      			auto: true,
      			pause: 5000,
      			responsive: true
      		});
      	});
      </script>


        Evolution user, I like the back-end speed and simplicity smiley
        • 50485
        • 56 Posts
        Hi fourroses666

        Thanks for taking the time to reply. Yes, I have set the base_url. My general css is working fine, but I can't tell if the bxslider css is as nothing is loading which I am guessing is a javascript issue. Do you think there might be a problem that I have other code after the bx slider in the head? There is also some more script at the end of the page in a footer chunk. I have copied both below. Any advice much appreciated!

        <!DOCTYPE html>
        <html>
        <head>
        	<meta charset="UTF-8">
        	
        	<title>[[++site_name]] - [[*pagetitle]]</title>
        	<base href="[[++site_url]]" />
        	
        	<meta name="description" content="[[*description]]"/>
        	<meta name="keywords" content="[[*introtext]]"/>
        
        	<!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]-->
        	<!-- viewport checks-->
        	
        	<meta name="viewport" content="width=device-width, maximum-scale=1.0, minimum-scale=1.0, initial-scale=1.0" />	
            
        	<link rel="stylesheet" type="text/css" href="assets/css/reset.css" />
        	
        	<link rel="stylesheet" type="text/css" href="assets/css/style.css" />
        	<!--image slider links-->
        		
        <!-- jQuery library (served from Google) -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
        <!-- bxSlider Javascript file -->
        <script src="assets/js/bxslider/jquery.bxslider.min.js"></script>
        <!-- bxSlider CSS file -->
        <link href="assets/css/bxslider/jquery.bxslider.css" rel="stylesheet" />
        <script>$(document).ready(function(){
          $('.bxslider').bxSlider();
        });
            </script>
         	
         	<!--full screen script for home page-->
        	
        	<script src="assets/js/fullheight.js"></script>
        	
        	<!--navigation code-->
        	
        	<link rel="stylesheet" href="assets/js/menu/dist/slicknav.css">
        	
        	<script src="http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
        	
        	<!--favicon-->
        	
        	<link rel="shortcut icon" href="assets/images/favicon.ico"/>
        	
        	<!--Google analytics script-->
        	
        	<script>
        		(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        			(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
        			m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          			})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
        
        			ga('create', 'UA-59969111-2', 'auto');
        			ga('send', 'pageview');
        	</script>
        
        </head>
        


        ..........................




        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
        <script src="assets/js/menu/dist/jquery.slicknav.js"></script>
        <script type="text/javascript">
        $(document).ready(function(){
        	$('#menu').slicknav();
        });
        </script>  
          • 9995
          • 1,613 Posts
          You have to place you jquery script always on top of the other scripts and dont need to call it twice.

          So you can remove the bottom call:
          <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>


          What I normally do is place the jquery call in the head and all other scripts in the footer before </body>
          Start with your CSS and then scripts
            Evolution user, I like the back-end speed and simplicity smiley
            • 50485
            • 56 Posts
            fourroses666 - THANK YOU!!!!

            I am very grateful for your help. May I just ask you one more thing as a user of the bxslider. I am new to MODX so looking at how best to allow a user to upload images to the slider. Do you do this, and if so do you just use a tv for each image or a get images call?

            Again, thanks for helping me sort this. Much appreciated.

            Missusdoubleyou
              • 9995
              • 1,613 Posts
              Yes, that could be a way to do this.
              You need to use something like, when TV is empty then dont show the banner image.
              Something like:
              [[If? [[*banner-img-01]]=``:then=``:else=`<li><img src="" /></li>` ]]

              If you used Evolution I could help you more with it, I actually don't know what's being used for it lol.


              ###edit:

              http://rtfm.modx.com/extras/revo/if

              [[If?
              &subject=`[[*banner-image01]]`
              &operator=`EQ`
              &operand=`1`
              &then=``
              &else=`<li><img src="[[*banner-image01]]" /></li>`
              ]]
              [[If?
              &subject=`[[*banner-image02]]`
              &operator=`EQ`
              &operand=`1`
              &then=``
              &else=`<li><img src="[[*banner-image02]]" /></li>`
              ]]
              etc..

              But there must be other ways to do this.


              Probably with MIGX [ed. note: fourroses666 last edited this post 11 years, 4 months ago.]
                Evolution user, I like the back-end speed and simplicity smiley
                • 50485
                • 56 Posts
                Hi ya

                I am using MODX cloud to publish a site on historic buildings were I live (its a project for my masters). So for each page with info about a building I will be using bxslider to show some photos of it.
                  • 9995
                  • 1,613 Posts
                  I see there is some plugin for slideshows but haven't used it.
                  http://modx.com/extras/package/slideshowmanager

                  Its hard to advise you with something I haven't done yet in Revolution smiley

                  The option I gave to use If and just some custom image TV's will probably the easiest and fastest way.
                  When you want to use many images and titles / text then you will have to use allot of TV's.
                  There are probably "better" options to do it like the MIGX but can't help you with that.

                  Good luck smiley
                    Evolution user, I like the back-end speed and simplicity smiley
                    • 50574
                    • 70 Posts
                    I have used BXslider in Revo and would suggest using the MigX extra to create a TV that you can add multiple images to the same chunk template.
                    Good documentation on getting started with MigX:
                    http://rtfm.modx.com/extras/revo/migx
                    and check the links at the bottom of that page for frontend/backend usage.

                    Basically, you need to create a TV and change the input options to MigX from the dropdown then add form tabs (the items that will be user inputted)
                    [
                    {"caption":"Images", "fields": [
                        {"field":"image","caption":"Slider image","inputTVtype":"image"}
                    ]}
                    ] 
                    

                    and the grid columns (how the info is shown in the table list)
                    [
                    {"header": "Image", "width": "200", "sortable": "true", "dataIndex": "image","renderer": "this.renderImage"}
                    ]
                    

                    Create a chunk to for the item
                    <li>
                    <img src="[[+image]]" alt="image name" />
                    </li>

                    and then call the TV in your resource template
                    <div id="carousel-container">
                    <ul class="bxslider">
                    [[!getImageList? 
                    &tvname=`imageSlider`
                    &tpl=`imageSliderItem`]]
                    </ul>
                    </div>


                    A good video tutorial that may help you to visualise how it works:
                    https://www.youtube.com/watch?v=adU2d8V4y3E and I'd also advise watching the others in Jesse Showalter's series, they were a great help to me as a beginner too.
                      • 50675
                      • 13 Posts
                      Is there any way to force images to fit to container height/width?