Empire cms loads more implementations (both parent and child columns can be implemented)

Keywords: PHP SQL JQuery

1,

<div class="pagelist"> <span id="loadmore" class="btn" style="display: block;">Load more</span> </div>

Find the button to load more and set the id (preferably id, which is easier to traverse).

2,

<ul id="showajaxnews" style="opacity: 1; top: 0px;">

        [!--empirenews.listtemp--]<!--list.var1-->[!--empirenews.listtemp--]

</ul>

Find the label of the list content template and set the id.

3,

<script>
  $(function () {
    var i = 1;
    $('#loadmore').click(function () {
      $.ajax({
        url: 'domain name/e/action/getmore.php',
        type: 'POST',
        data: {
          "next": i,
          'table': 'news',
          'classid': '[!--self.classid--]', /*The current id obtained by this tag*/
          'action': 'getmorenews',
          'limit': 4,
          'small_length': 120
        },
        dataType: 'html',
        beforeSend: function () {
          $("#loadmore").show().html(
            '<img src="/images/loaduai.gif" alt="Trying to load...');
          $('#loadmore').attr('disabled', 'disabled');
        },
        success: function (data) {
          if (data) {
            $("#showajaxnews").append(data);
            $("#loadmore").removeAttr('disabled');
            $("#loadmore").html('Click to load more');
            i++;
          } else {
            $("#loadmore").show().html("All loaded!");
            $('#loadmore').attr('disabled', 'disabled');
            return false;
          }
        }
      });
    });
  });
</script>

ajax is put under load more, remember to introduce Jquery

4,

The bottom is marked in red. I made a judgment of $classid here, which means that when the column is the parent column 7, all data of columns id 8 and 9 will be called. Just follow your own scenario settings.

<?php
require('../class/connect.php');
require('../class/db_sql.php');
require('../data/dbcache/class.php');
if ($_POST[action] == 'getmorenews') {
    $table = htmlspecialchars($_POST[table]);
    if (empty($_POST[orderby])) {
        $orderby = 'newstime';
    } else {
        $orderby = htmlspecialchars($_POST[orderby]);
    }
    if (empty($_POST[myorder])) {
        $myorder = 'desc';
    } else {
        $myorder = 'asc';
    }
    if (empty($_POST[limit])) {
        $limit = 6;
    } else {
        $limit = (int) $_POST[limit];
    }
    if (empty($_POST[classid])) {
        $where = null;
    } else if ($_POST[classid] == 7) {
        $where = 'where classid in("8,9")';
    } else {
        $where = 'where classid in(' . $_POST[classid] . ')';
    }
    if (empty($_POST[length])) {
        $length = 50;
    } else {
        $length = (int) $_POST[length];
    }
    if (empty($_POST[small_length])) {
        $small_length = 500;
    } else {
        $small_length = (int) $_POST[small_length];
    }

    // next: Page
    // Table: call data table
    // limit: number of calls per time
    // small_length: introduction number of characters intercepted
    // length: number of characters for header truncation
    // classid: call column. Multiple columns are allowed, such as 1, 2, 3 and 4. Note that it must be columns calling the same data table
    // Order by: sort. The default is newstime. You can sort by what you pass, such as id
    // myorder: positive and negative order. The default is asc. How about desc

    $link = db_connect();
    $empire = new mysqlquery();
    $num = (int) $_POST['next'] * $limit;

    if ($table) {
        $sql = $empire->query("SELECT * FROM `" . $dbtbpre . "ecms_" . $table . "` $where order by $orderby $myorder limit $num,$limit");

        while ($r = $empire->fetch($sql)) {

            if ($r[mtitlepic] == '') {
                $r[mtitlepic] = $public_r[news . url] . "e/data/images/notimg.gif";
            }
            $oldtitle = stripSlashes($r[title]);
            $title = sub($oldtitle, '', $length);
            $smalltext = stripSlashes($r[smalltext]);
            $smalltext = sub($smalltext, '', $small_length);
            $classname = $class_r[$r[classid]][classname];
            $newsurl = $public_r[newsurl];
            $classurl = $newsurl . $class_r[$r[classid]][classpath];
            $urls = sys_ReturnBqTitleLink($r);

            ?>
            <!-- The following code is the label template of the display list, which can be modified according to the situation.-->
            <li>
                <a href="<?= $urls ?>">
                    <div class="img">
                        <img src="<?= $r[titlepic] ?>" class="lazy"></div>
                    <div class="con">
                        <h2>
                            <?= $r[title] ?>
                        </h2>
                        <p>
                            <?= $r[smalltext] ?>
                        </p>
                        <span>
                            <?= date("Y-m-d", $r[newstime]) ?>
                        </span>
                    </div>
                    <div class="more">
                        <span></span>
                    </div>
                </a>
            </li>
<?php
        }
    }
}
db_close();
$empire = null;
?>

Create a getmore.php file and upload the upper code to the / e/action / file

Posted by php_man555 on Thu, 14 May 2020 07:33:19 -0700