1

Topic: Twitter-like Loadmore...

BY: Nida Elias (Masochist)
Phobia@hotmail.com

This tutorial was made for the "default" theme. Please follow these steps and don't forget to share it with others...

-------------------------------------
01 - /system/controllers/dashboard.php
-------------------------------------

BEFORE:
$not_in_groups    = '';

ADD:
$show    = 'all';
if( $this->param('show') && in_array($this->param('show'), $shows) ) {
    $show    = $this->param('show');
}
-------------------------------------

REMOVE:
if( $this->param('from') == 'ajax' )
{
    echo 'OK:';
    echo $D->posts_html;
    exit;
}
-------------------------------------

BEFORE:
$this->load_template('dashboard.php');

ADD:
    $D->num_results    = 0;
    $D->start_from    = 0;
    $D->posts_html    = '';
   
    if( $q1!='' && $q2!='' ) {
        $D->num_results    = $db2->fetch_field($q1);
        $D->start_from    = $this->param('start_from') ? intval($this->param('start_from')) : 0;
        $D->start_from    = max($D->start_from, 0);
        $D->start_from    = min($D->start_from, $D->num_results);
        $res    = $db2->query($q2.'LIMIT '.$D->start_from.', '.$C->PAGING_NUM_POSTS);
        $D->posts_number    = 0;
        ob_start();
        while($obj = $db2->fetch_object($res)) {
            $D->p    = new post($obj->type, FALSE, $obj);
            if( $D->p->error ) {
                continue;
            }
            $D->posts_number    ++;
            $D->p->list_index    = $D->posts_number;
            $this->load_template('single_post.php');
        }
        unset($D->p);
        $D->posts_html    = ob_get_contents();
        ob_end_clean();
    }
   
    if( $this->param('from') == 'ajax' ) {
        echo 'OK:'.$D->posts_number.':';
        echo $D->posts_html;
        exit;
    }

   
    if( $show=='all' || $show=='@me' || $show=='private' || $show=='commented' || $show=='feeds' ) {
        $this->network->reset_dashboard_tabstate($this->user->id, $show);
    }

-------------------------------------
02 - /themes/yourtheme/html/header.php
-------------------------------------

BEFORE:
<base href="<?= $C->SITE_URL ?>" />

ADD:
<script type="text/javascript" src="<?= $C->SITE_URL.'themes/'.$C->THEME ?>/js/mobile_iphone.js"></script>

-------------------------------------
03 - /themes/yourtheme/html/dashboard.php
-------------------------------------

REPLACE:
<div id="posts_html">
    <?= $D->posts_html ?>
</div>


WITH:
<div id="posts_html">
    <?php if( $D->num_results == 0 ) { ?>
    <div class="alert yellow"><?= $this->lang('dbrd_nores_'.$D->show) ?></div>
    <?php } else { ?>
        <?= $D->posts_html ?>
    <?php } ?>
</div>
-------------------------------------

BEFORE:
<?php
    $this->load_template('footer.php');
?>

ADD:
<?php if( $D->num_results > $D->posts_number ) { ?>
    <div id="loadmore">
        <div id="loadmore2">
        <div id="loadmoreloader" style="display:none;"></div>
        <a id="loadmorelink" href="javascript:;" onclick="load_more_results('posts_html', <?= $D->posts_number ?>, <?= $D->num_results ?>);"><b><strong><?= $this->lang('iphone_paging_posts') ?></strong></b></a>
        </div>
    </div>
<?php } ?>


-------------------------------------
04 - /themes/yourtheme/css/inside.css
-------------------------------------

ADD:
/***/
#loadmore {
    height: 27px;
    width:510px;
    background-color: #eee;
    background-image:url('../imgs/ttl.gif');
    background-position:top right;
    margin-left:214px;
    overflow:visible;
    margin-top:5px;
    line-height:1.2;
    position:relative;
}
#loadmore2 {
    height: 27px;
    background-image:url('../imgs/ttl2.gif');
    background-position:top left;
    background-repeat:no-repeat;
    overflow:visible;
}
#loadmoreloader {
    position:absolute;
    top:-2px;
    left:-40px;
    width:36px;
    height:36px;
    background-image:url('../imgs/post_loader.gif');
    display:none;
}
#loadmore a {
    display:block;
    float:left;
}
#loadmore a b {
    display:block;
    float:left;
    padding:6px;
    padding-bottom:7px;
    cursor:pointer;
}
/****/

-------------------------------------
05 - /themes/yourtheme/imgs/
-------------------------------------

COPY THIS IMAGE TO THE FOLDER:
post_loader.gif

http://www.mjaddara.com/images/post_loader.gif

PS. Save this image as "post_loader.gif"
-------------------------------------

ENJOY......... http://sharetronixguide.com/img/smilies/smile.png

Thumbs up +3 Thumbs down

2

Re: Twitter-like Loadmore...

http://www.mjaddara.com/images/loadmore-screen.jpg

Thumbs up Thumbs down

3

Re: Twitter-like Loadmore...

Thank you!!! [img]../../../img/smilies/big_smile.png[/img]

Thumbs up Thumbs down

4

Re: Twitter-like Loadmore...

Thank you Masochist.  For sharing this long  awaited feature. You have done it!

Install Turnkey Web Scripts start your own profit portals
Do someMicro Jobs and earn decent money on your part time

5

Re: Twitter-like Loadmore...

Guys, don't forget to add the language line in the dashboard.php.

system/languages/en/inside/dashboard.php

'iphone_paging_posts'    => 'Load more posts...',

Thumbs up Thumbs down

6

Re: Twitter-like Loadmore...

http://imm.io/media/1c/1cyQ.png
I get this ":15" after the dashboard makes autorefresh.

German Sharetronix Support and development on:
http://Pixel4Tune.de

7

Re: Twitter-like Loadmore...

It breaks the page in internet explorer (default theme) and i also see a number like Zeronix

Thumbs up Thumbs down

8

Re: Twitter-like Loadmore...

http://img838.imageshack.us/img838/9541/windowsinternetexplorer.jpg

Uploaded with ImageShack.us

Thumbs up Thumbs down

9

Re: Twitter-like Loadmore...

Thank you very much!

I come from the great Chinese!

Thumbs up Thumbs down

10

Re: Twitter-like Loadmore...

very Nice http://sharetronixguide.com/img/smilies/smile.png
but, how to remove this Number ?

Sharetronix.ir

11

Re: Twitter-like Loadmore...

mine was 14....i gave up...

Thumbs up Thumbs down

12

Re: Twitter-like Loadmore...

hehe... I know guys, and I am trying to fix it. In fact, the number is the number of posts placed in the conf_system.php. I would love if you guys can find anyone to fix it because I will give up in two hours smile

PS. It's the first time in my life I do some php editing... so for me, it was perfect smile

Thumbs up Thumbs down

13

Re: Twitter-like Loadmore...

If i´d knew the line and the file i could make a css code to make the fontsize of the problem "0" and #FFF.This would be the simplest solution.

German Sharetronix Support and development on:
http://Pixel4Tune.de

14

Re: Twitter-like Loadmore...

Can this be done for Blu-sky theme?Thanks in advance

Thumbs up Thumbs down

15

Re: Twitter-like Loadmore...

@Urosh
Hey BuddyThis script is working for all themes.The only problem we´re working on is the screenshot i posted above.Before this is fixed you should wait wink
You can see what i mean on my site (you´re still registered) wink

German Sharetronix Support and development on:
http://Pixel4Tune.de

16

Re: Twitter-like Loadmore...

Bug, how to delete a number that is displayed? http://sharetronixguide.com/img/smilies/smile.png

Thumbs up Thumbs down

17

Re: Twitter-like Loadmore...

Hello The Problem with Numbers Comming from path to Js  just  fixed with your path
example
Old   Code
        <script type="text/javascript" src="<?= $C->SITE_URL.'themes/'.$C->THEME ?>/js/mobile_iphone.js"></script>
just  make it like other  ones
        <script type="text/javascript" src="<?= $C->SITE_URL ?>themes/default/js/mobile_iphone.js"></script>
also  dont forget to put your language to show Load More
Great Work 
Masochist

Never say Never
Hire Me here http://www.dirwns.com
My Social Network http://www.cukni.com

18

Re: Twitter-like Loadmore...

this not fix the problem xmm I think you can check JS mobile version there is a future to show these numbers
mine is 10: this is the number of post in your dashboard
Definetly the problem comming from js mobile file

function load_more_results(div_id, current_results, all_results) {
    current_results    = parseInt(current_results, 10);
    all_results        = parseInt(all_results, 10);
    var url    = w.location.href.toString();
    if( ! url ) { return; }
    if( url.substr(0, siteurl.length) == siteurl ) {
        url    = url.substr(siteurl.length);
        if( url.indexOf("#") != -1 ) {
            url    = url.substr(0, url.indexOf("#"));
        }
        url    = siteurl+url+"/from:ajax"+"/start_from:"+(current_results+1)+"/r:"+Math.round(Math.random()*1000);
    }
    else {
        url    = url.replace(/^http(s)?\:\/\//, "");
        url    = url.substr(url.indexOf("/"));
        if( url.indexOf("#") != -1 ) {
            url    = url.substr(0, url.indexOf("#"));
        }
        url    = siteurl+url+"/from:ajax"+"/r:"+Math.round(Math.random()*1000);
    }
    var req    = ajax_init(false);
    if( ! req ) { return false; }
    req.onreadystatechange    = function() {
        if( req.readyState != 4  ) { return; }
        var txt    = trim(req.responseText);
        var num    = txt.match(/^OK\:([0-9]+)\:/g);
        if( ! num ) { return; }
        num    = num.toString().match(/([0-9]+)/);
        num    = parseInt(num, 10);
        if( ! num ) { return; }
        txt    = txt.replace(/^OK\:([0-9]+)\:/, "");
        txt    = trim(txt);
        var dv    = d.createElement("DIV");
        dv.innerHTML    = txt;
        d.getElementById(div_id).appendChild(dv);
        setTimeout( function() { my_scroll_page_to(dv.offsetTop-30); }, 5);
        if( current_results+num+1 >= all_results ) {
            d.getElementById("loadmore").style.display    = "none";
        }
        d.getElementById("loadmorelink").onclick    = function() {
            load_more_results(div_id, current_results+num+1, all_results);
        };
        d.getElementById("loadmoreloader").style.display    = "none";
    }
    req.open("GET", url, true);
    req.send("");
    d.getElementById("loadmoreloader").style.display    = "block";
    d.getElementById("loadmorelink").blur();
}

Must be some of this code here but i will try in Monday

Never say Never
Hire Me here http://www.dirwns.com
My Social Network http://www.cukni.com

19

Re: Twitter-like Loadmore...

Hello guys... did anyone find a fix for the number?

Thumbs up Thumbs down

20

Re: Twitter-like Loadmore...

If you remove this line of code "echo 'OK' .$D->posts_number.':';  the number does not show anymore. But then the posts dont load neither. Is there some way to hide this output from displaying on the site?

Thumbs up Thumbs down

21

Re: Twitter-like Loadmore...

My site will be perfect if only i can get this number gone. Please can any admin help us solve this issue.

Thumbs up Thumbs down

22

Re: Twitter-like Loadmore...

http://sharetronixguide.com/img/smilies/big_smile.png thanks

Please +rep Like My Work Or visit List site here.
here my sharetronix site http://www.odestory.com
Social Media http://storiesMe.com

Thumbs up Thumbs down

23

Re: Twitter-like Loadmore...

i dont know how to remove that number. and one thing i noticed when i scroll to top it automatically displays only 10 post again just like the situation before clicking load more.
--

Thumbs up Thumbs down

24

Re: Twitter-like Loadmore...

lol.. for a simple remove the number just using css style

<div id="posts_html" style="color:#fff;">
</div>
but its not good idea...


http://sharetronixguide.com/img/smilies/yikes.pnghttp://sharetronixguide.com/img/smilies/wink.pnghttp://sharetronixguide.com/img/smilies/hmm.pnghttp://sharetronixguide.com/img/smilies/lol.png

Thumbs up Thumbs down

25

Re: Twitter-like Loadmore...

Thank you this share!!!
Fot those that wants to do the same thing for the Profile pages, just follow the same steps in controllers/user.php and theme/html/user.php, Finally add the language line in language/inside/user.php: 'iphone_paging_posts'    => 'Load more posts...',
Anyone knows how to that fkn number???

Last edited by aaronrrc (2011-12-04 06:28:58)

Thumbs up Thumbs down