Forum Replies Created

Viewing 15 replies - 31 through 45 (of 103 total)
  • Thread Starter downfast

    (@downfast)

    Follow up on this:

    jQuery.fn.almComplete = function(alm){
      if(!$("body").hasClass("loadedList")) {
      		setTimeout(function(){
    			$("body").addClass("loadedList");
    			pos = jQuery("#list").height();
      		}, 2000);
      } else {
    	$("body, html").animate({scrollTop:'+=' + pos + 'px'}, 1000).offset().top;
      }
    }

    Basically I am checking if the body has a class on content loaded, if it does not, I am awaiting for 2 secs for all content to be properly loaded and layed out with isotope (masonry) and setting a global var for the container height. Afterwards when loading new content, I am skipping to set the height as the body has the class and I am scrolling to that var height px.

    Since I am loading different amount of content if we are on mobile I am doing this in my index.php

    <div id="list" class="cs-style-5">
                <?php function detectmobile(){
                    $agent = $_SERVER['HTTP_USER_AGENT'];
                    $useragents = array (
                        "iPhone",
                        "iPod",
                        "Android",
                        "blackberry9500",
                        "blackberry9530",
                        "blackberry9520",
                        "blackberry9550",
                        "blackberry9800",
                        "webOS"
                    );
                    $result = false;
                    foreach ( $useragents as $useragent ) {
                        if (preg_match("/".$useragent."/i",$agent)){
                            $result = true;
                        }
                    }
                    return $result;
                }
                if (detectmobile() == true) { ?>
                    	<?php echo do_shortcode('[ajax_load_more post_type="page" seo="true" posts_per_page="4" scroll="false" button_label="+ MORE WORKS +" pause="false"]');
                } else { ?>
                        <?php echo do_shortcode('[ajax_load_more post_type="page" seo="true" posts_per_page="10" scroll="false" button_label="+ MORE WORKS +" pause="false"]'); ?>
                    <?php }  ?>
                </div>
            </div>

    So I am loading only 4 posts if we are on mobile and 10 if we are on desk. Since we are loading only 4 posts, when on mobile I need to scroll to half of the container height like this:

    if(!$("body").hasClass("loadedList")) {
      		setTimeout(function(){
    			$("body").addClass("loadedList");
    			pos = jQuery("#list").height();
      		}, 2000);
    } else {
    	var newPos = pos / 2;
    	$("body, html").animate({scrollTop:'+=' + newPos + 'px'}, 1000).offset().top;
    }

    not sure if this is the proper solution but it is A solution. Hope it helps

    Thread Starter downfast

    (@downfast)

    Quick update on this:

    It’s not a real solution maybe but this is what I thought so far:

    var pos = $("#list").height();
    jQuery('html, body').animate({scrollTop:'+=' + pos + 'px'}, 1000).offset().top;

    $(“#list”).height is the height of the isotope (masonry) container when it first loads, then each time I am loading new content, I am scrolling the window for as much as the saved height of the container at the beginning.

    Thread Starter downfast

    (@downfast)

    OK i think is this bit

    almSEO.getCurrentPageTop = function(page){
    
              // Get children
             var objs = $('.alm-reveal').eq(0).children() ? $('.alm-reveal').eq(0).children() : '';   
    
             if(objs.length){
                var objType = objs[0].nodeName.toLowerCase(),
                    obj = page * almSEO.postsPerPage - almSEO.postsPerPage;    
    
                var objSelected = $('.alm-listing .alm-reveal > ' + objType).eq(obj); 
    
                if(almSEO.scroll) almSEO.scrollToPage(objSelected);
    
             }
          }

    But I am using isotope (masonry) therefore may change the container height. Any idea?

    Thread Starter downfast

    (@downfast)

    Just wanted to layout the button within my template without to use js, I guess I will just change where it is appending to tho.

    Will let you know if i manage to dave the window pos to have the back/fwd work with masonry and isotope.

    Thanks

    Thread Starter downfast

    (@downfast)

    how about if we could perhaps save the amout of px the window scrolled on post load and remember that when we back and forward press?

    Thread Starter downfast

    (@downfast)

    Ok it makes perfect sense.

    On another quick note: is there a way to add the button manually to load more posts rather than appending it via jQuery?

    Thans man

    Thread Starter downfast

    (@downfast)

    Thanks to an answer from wordpress stack I got this solution:

    add this to your functions.php

    register_nav_menus(array(
    'top-menu' => __('Menu1', 'twentyfourteen'),
    'side-menu' => __('Menu2', 'twentyfourteen'),
    'footer-menu' => __('Menu3', 'twentyfourteen')
    )
    );
    function my_walker_nav_menu_start_el($item_output, $item, $depth, $args) {
        $menu_locations = get_nav_menu_locations();
    
        if ( has_term($menu_locations['top-menu'], 'nav_menu', $item) ) {
           $item_output = preg_replace('/<a /', '<a class="list-group" ', $item_output, 1);
        }
    
        return $item_output;
    }
    add_filter('walker_nav_menu_start_el', 'my_walker_nav_menu_start_el', 10, 4);

    at last you must select the option “Menu1” for the specific menu on which you have to add the anchor custom classes from dashboard Apperance->menus. [select menu2 or menu3 for other menus whose anchor links does not need the custom-class]

    To add “active class” to the first menu item of the particular menu then try this one:

    function my_walker_nav_menu_start_el($item_output, $item, $depth, $args) {
        $menu_locations = get_nav_menu_locations();
    
        if ( has_term($menu_locations['top-menu'], 'nav_menu', $item) ) {
           $item_output = preg_replace('/<a /', '<a class="list-group" ', $item_output, 1);
    if ($item->menu_order == 1){
     $item_output = preg_replace('/<a /', '<a class="list-group active" ', $item_output, 1);
    }
        }
    
        return $item_output;
    }
    add_filter('walker_nav_menu_start_el', 'my_walker_nav_menu_start_el', 10, 4);

    if the active class must be added to the first menu item of all menus then use this:

    function my_walker_nav_menu_start_el($item_output, $item, $depth, $args) {
        $menu_locations = get_nav_menu_locations();
    
        if ( has_term($menu_locations['top-menu'], 'nav_menu', $item) ) {
           $item_output = preg_replace('/<a /', '<a class="list-group" ', $item_output, 1);
        }
     if ($item->menu_order == 1){
     $item_output = preg_replace('/<a /', '<a class="active" ', $item_output, 1);
    }
        return $item_output;
    }
    add_filter('walker_nav_menu_start_el', 'my_walker_nav_menu_start_el', 10, 4);
    Thread Starter downfast

    (@downfast)

    I have already bought the eStore plugin, however even in there I have an issue as the thumbnail is displayed only if we provide a URL of an image to be used while inseatd it would be much better if that thumbnail would be generated by the product page post_thumbnail automatically. See the forum post

    Thread Starter downfast

    (@downfast)

    It’s about showing the checkout page with the product thumbnail, not much to show to be honest. The custom checkout page currently retrieve the product name and the link but I am trying to also display the product thumbnail.

    Currently I add to a custom page called checkout:

    [show_wp_shopping_cart]

    I tried to edit the plugin but i can get the page to also show the product thumbnail on the actual checkout page

    Thanks

    Thread Starter downfast

    (@downfast)

    nice-login-register-widget/pw-login-widget.php

    Just in case this can help anyone, in order to place the additional fields before the “Sign up” button, such as those fields created using Register Plus Redux or Cimy User Extra Fields plugin (actually this is what I use), I had to use jQuery:

    $(".sp-widget-register-div input[value='Sign up!']").insertBefore(".sp-widget-register-div #wp-social-login-connect-with");
    var duplicateChk = {};
    $(".sp-widget-register-div input[value='Sign up!']").each (function () {
        	if (duplicateChk.hasOwnProperty(this)) {
           		$(this).remove();
        	} else {
           		duplicateChk[this] = 'true';
        	}
    });

    This isn’t the nicest solution as it should be made server side but it works nicely anyway. (Issue is where the user has js off, but it’s very rarely anyway). So there you go.

    @to the plugin Author: it’d be nice if you could include at least “user custom password” into the form so that we won’t need to use other plugins to get additional custom fields. I understand you want to keep it clean and simple but a custom possword field wouldn’t be too bad, I think. Thanks

    Thread Starter downfast

    (@downfast)

    Oh well, i’m opting for a registration unfortunatly. The unique name thing is far too complex to handle, the solution above is A solution but yet a user could copy the generated user name from another post author and use it as its own to post, so doesn’t really solve the issue.

    Unless you have some enlightenment i guess I should simply give up on the non registration and just go ahead with a registration approach.

    Thanks

    Well if you really need a quick solution for your field such as ask for an email, you could give up of one of the current fields and just change the text into Email.

    e.g. Find in the plugin files where the form field says Post URL and change it to: Your email and remove the link format

    if (is_user_logged_in()) {
        // the user is logged in, so display the submission form
        if (function_exists('user_submitted_posts')) user_submitted_posts();
    } else {
        // the user is not logged in, so redirect to any URL and exit
        header('Location: https://example.com/');
        exit;
    }

    As the FAQ says: https://www.ads-software.com/plugins/user-submitted-posts/faq/

    Thread Starter downfast

    (@downfast)

    or even bettr, in regards of the same name, I could check if the meta value already exists

Viewing 15 replies - 31 through 45 (of 103 total)