Make Grid View the default listing way in homepage

Discussion in 'ClassiCraft WordPress Theme' started by anuj, Jul 10, 2013.

  1. anuj

    anuj New Member

    Joined:
    May 28, 2013
    Messages:
    14
    Likes Received:
    0
    Location:
    New Delhi
    Hello
    Please let me know how to make the grid view as the detail ad listing view in homepage


    thanks in advance
     
  2. careykidd

    careykidd New Member

    Joined:
    Feb 18, 2015
    Messages:
    19
    Likes Received:
    0
    #bump -- How do you make Gridview the Default?
     
  3. spottedvarennes

    spottedvarennes Member

    Joined:
    Jan 26, 2015
    Messages:
    79
    Likes Received:
    0
    quick solution, you have to modify this in the template files (index.php and template_cate.php. In those file you'll see a javascript function when the DOm document is ready, you need to add this code
    so the javascript will click the gridView for you
    simply add this after the function (look for it in the code below)
    jQuery('#gridview').click();

    Code:
        <script type="text/javascript">
            jQuery(document).ready(function ($) {
                $("a.switcher").bind("click", function (e) {
                    e.preventDefault();
     
                    var theid = $(this).attr("id");
                    var theproducts = $("ul#products");
                    var classNames = $(this).attr('class').split(' ');
                    var postmeta = $(".post_meta");
                    var text = $(".contents p");
                    var gridthumb = "images/products/grid-default-thumb.png";
                    var listthumb = "images/products/list-default-thumb.png";
     
                    if ($(this).hasClass("active")) {
                        // if currently clicked button has the active class
                        // then we do nothing!
                        return false;
                    } else {
                        // otherwise we are clicking on the inactive button
                        // and in the process of switching views!
     
                        if (theid == "gridview") {
                            $(this).addClass("active");
                            $("#listview").removeClass("active");
     
                            $("#listview").children("img").attr("src", "images/list-view.png");
     
                            var theimg = $(this).children("img");
                            theimg.attr("src", "images/grid-view-active.png");
     
                            // remove the list class and change to grid
                            theproducts.removeClass("list");
                            theproducts.addClass("grid");
                            //$('.rating').hide();
                            postmeta.hide();
                            text.hide();
                            // update all thumbnails to larger size
                            //$("img.thumb").attr("src",gridthumb);
                        }
     
                        else if (theid == "listview") {
                            $(this).addClass("active");
                            $("#gridview").removeClass("active");
                        //    $('.rating').show();
                            $("#gridview").children("img").attr("src", "images/grid-view.png");
     
                            var theimg = $(this).children("img");
                            theimg.attr("src", "images/list-view-active.png");
                            postmeta.show();
                            text.show();
                            // remove the grid view and change to list
                            theproducts.removeClass("grid")
                            theproducts.addClass("list");
                            // update all thumbnails to smaller size
                            //$("img.thumb").attr("src",listthumb);
                        }
                    }
     
                });
              jQuery('#gridview').click();
            });
     
        </script>
     
  4. careykidd

    careykidd New Member

    Joined:
    Feb 18, 2015
    Messages:
    19
    Likes Received:
    0
    does this still work?? I updated my theme and forgot to do a child theme.. this doesn't seem to be working for me anymore
     
  5. careykidd

    careykidd New Member

    Joined:
    Feb 18, 2015
    Messages:
    19
    Likes Received:
    0

Share This Page