0

Hello, I got problem to write code excerpt in my article.

CREATE TABLE IF NOT EXISTS 'articles' (
'id' int(11) NOT NULL AUTO_INCREMENT,
'title' varchar(250) NOT NULL,
'body' text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;

INSERT INTO 'articles' ('id', 'title', 'body') VALUES
(1, 'Lorem', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry''s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.');

Article class

class Article_class {
  protected static $table_name = 'articles';
  public $id, $title, $body;
    public static function get_articles() {
      try {
        global $database_handle;
        $sql = "SELECT * FROM " . self::$table_name;
        $statement = $database_handle->sql_query($sql);
        $statement->setFetchMode(PDO::FETCH_OBJ);
        while($row = $statement->fetch()) {
          $data[] = $row;
        }
        return $data;
      } catch(PDOException $pdo_exception) {
        die("Error " . $pdo_exception->getMessage());
      }
    }
}

That code is working fine in my view template, What I really want is how to create the excerpt for 5 line. I already search in Google, but I can't find it, too many Wordpress excerpt code.

Btw where is the seacrh form, I can't find, in top is for all, not for PHP only.

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by pritaeas
0

Yeah, you're correct, after the fifth dot.

Actually, it doesn't really matter how many line or like you said truncate after dot, because I think it would be dynamic as a parameter.

Anyway in wordpress I see the trick is just add comment "<!--more-->" in the textarea, not sure, but I think wordpress use tinyMCE.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.