We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19872
    • 1,078 Posts
    After many hours and some helpful pointers from Mark Hamtra and his tutorials, I have successfully made operational a MIGx Flexsider setup in my site using getImageList. In my case, I opted not to use phpthumbof, because all of my images are pre-processed in photoshop. Eventually though, I can tell the phpthumbof will be an awesome tool.

    My goal for now is to have a slider on my home page, and just a static main image on other pages. The static image, I am handling with a TV. The slider is within a chunk.

    Is there a strategy for setting these up that will allow the user to decide between the two. More than likely the slider will only be a home page type item. So, do I need to create a separate template for a page with a slider, or is there a way to use my one main template, and only have scripts and css for the slider load when there is actually a slider on the page.

    It might be nice to offer my friend the option on each page of his site, thhe choice to go with a static image, or a slider with multiple images. I saw some reference to this in menno's Flexibility, but no longer have access to those files to review. I remember his markups on the template page of "has slider on page" or something like that—which led my to think there's a way to create an option in the control panel when the user could determine whether or not to install a slider on a page.

    MODx has such a terrific forum and community. I truly appreciate any feedback or pointers, and can only hope that eventually, I might know enough to do the same.
      • 37105
      • 194 Posts
      You could create a Template Variable of the type Checkbox for the user to "enable" a slider. Then in your template read the value of this TV and set static image or a slider depending on the state of checkbox.
        Codeplaza Webdesign: for professional websites at low cost
        • 19872
        • 1,078 Posts
        Excellent. Sounds easy enough. Will give it a go.

        Thank you for the feedback.
          • 10208 ☆ A M B ☆
          • 1,780 Posts
          Menno uses the If snippet to display the slider or not.

          i.e.
          [[!If? &subject=`sliderOption` &operator=`EQ` &operand=`1` &then=`sliderChunk` &else=`imageChunk`]]


          Edit: fixed this call [ed. note: frogabog last edited this post 13 years, 2 months ago.]
            Frogabog- MODX Websites in Portland Oregon
            "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
            Having server issues? These guys have MODX Hosting perfected - SkyToaster
            • 19872
            • 1,078 Posts
            That's it! Thank you for reminding and clarifying. Very helpful.

            There does seem to be various schools of thought with the javascript—put it in the head, put it down near the body. Is there any reason, it could not just be included with the chunk that contains the slider? That way, when the slider gets chosen and inserted, the script comes along with.

            I'm referring to this bit of code that links to the .js file as well as the script that provides instruction for the slider (speed, transition type, etc. etc.)

            <!--Begin flexslider js and scripts-->
            <script src="assets/javascripts/jquery.flexslider.js"></script>
              <script type="text/javascript">
                $(window).load(function(){
                  $('.flexslider').flexslider({
                    animation: "slide",
                    controlNav: false,
                    start: function(slider){
                      $('body').removeClass('loading');
                    }
                  });
                });
              </script>
            <!--End flexslider js and scripts--> 
              • 10208 ☆ A M B ☆
              • 1,780 Posts
              I think there's a better solution, but you can always put conditional filters on the css and js script calls in the footer (I assume you're not calling the files in the header). If would work, using roughly the same call as above, although simple conditional filters will as well.

              Typically I'll put the scripts into an included .js file rather than including it in the chunk itself which I find to be unwieldy, although you most certainly can include it that way. I'd also simply put the css into the main stylesheet as opposed to calling another stylesheet into the template, even conditionally. Along that same note, you could compile and minimize your js, including the Flexslider.
                Frogabog- MODX Websites in Portland Oregon
                "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                Having server issues? These guys have MODX Hosting perfected - SkyToaster
                • 19872
                • 1,078 Posts
                I can certainly include the css in my styles for the site. Definitely a great suggestion. I had been exploring information about the conditional filters, inserting css and js or other items in the header, but it kind of went over my head. I need to revisit with fresh coffee and a less tired brain.

                The css is minimal so including it in another style sheet that's already being called is definitely a great idea. Between foundation, web fonts, and my own other related files, there's a lot of linking out to stuff going on, for what seems like on the surface a very simple design.

                In terms of minimizing, I've had mixed experiences with that. On another site, using the minimized version did not work. Could have been a server issue, or a user (i.e. moi ) issue with the link path. At any rate, I personally like having the styles available for me to edit whenever I need to.
                  • 10208 ☆ A M B ☆
                  • 1,780 Posts
                  Foundation comes in two flavors for css and js includes. The unminimized versions of each js file can be used separately, or you can use the minimized versions. The single files are simply shown/used for development purposes. If you want to only use some, then you'll want to minimize the js yourself and only include the ones you intend to use.

                  Alternately, the minimized css for foundation can simply be called up, and you would override that as needed in your own stylesheet.

                  You may also be interested in pulling Foundation from a CDN. http://cdnjs.com/ has nearly everything available out there with versioning even, including Foundation, jQuery, and modernizer.

                  An additional tool would be the MODX Extra, ClientConfig. http://modx.com/extras/package/clientconfig

                  With ClientConfig, you can include the scripts from the components menu in the manager, and update them as needed rather easily.
                    Frogabog- MODX Websites in Portland Oregon
                    "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                    Having server issues? These guys have MODX Hosting perfected - SkyToaster
                    • 19872
                    • 1,078 Posts
                    Thanks for the tips. Well....I know what I'll be doing for the rest of the evening.
                      • 10208 ☆ A M B ☆
                      • 1,780 Posts
                      YW, enjoy!

                      Oh, and it's very acceptable to have more than one template for you site. Home/landing pages are most often very different than the inner pages, and while MODX makes it simple to do it with just one template, it can also be simpler to make more than one template. Heck, even 3 or 4 isn't too many for a site that has some distinct variations.

                      Keep in mind, that every time MODX passes a conditional element, it has to process it. If only one page is going to use something, it's far more efficient to template it out separately.

                      Another approach is to use GetCache and keep MODX from processing things it doesn't have to once the cache is loaded.
                      http://devries.jp/blog/2013/03/23/cash-in-big-with-modx-cacheing/

                      Another interesting read is http://modx.com/blog/2012/09/14/tags-as-the-result-or-how-conditionals-are-like-mosquitoes/


                        Frogabog- MODX Websites in Portland Oregon
                        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                        Having server issues? These guys have MODX Hosting perfected - SkyToaster