LemonStand Version 1 Has Been Discontinued
This documentation is for LemonStand Version 1. LemonStand is now offered as a cloud-based eCommerce platform.
You can try the new LemonStand and learn about upgrading here.
Blog_Post class
The Blog_Post class represents a blog post. It contains fields for accessing a blog post title, description, content and other properties.
Class fields
- $title - post title
- $url_title - URL title of the blog post, for example "what_is_lemonstand"
- $categories - a list of categories the post belongs to. An instance of the Db_DataCollection class. Each element in the collection is an instance of the Blog_Category class.
- $description - a short description of the blog post
- $content - the blog post content, in HTML format
- $comments_allowed - indicates whether comments are allowed for this blog post. You can allow or deny comments for a specific post on the Create/Edit Post page in the Administration Area.
- $published_date - the post publication date. An instance of the Phpr_DateTime class.
- $comment_num - number of all blog post comments
- $approved_comment_num - number of approved blog post comments.
- $comments - a list of all blog post comments. An instance of the Db_DataCollection class. Each element in the collection is an instance of the Blog_Comment class.
- $approved_comments - a list of approved blog post comments. An instance of the Db_DataCollection class. Each element in the collection is an instance of the Blog_Comment class.
- $author_first_name - a first name of the post author
- $author_last_name - a last name of the post author
Class methods
- create() - creates an instance of the Blog_Post class. Static method.
- paginate($page_index, $items_per_page) - paginates a blog post list. Call this method before calling the find_all() method.
- find_all() - returns a collection of blog posts.
- find_by_url_title($url_tutle) - returns a blog post by its URL title. Example:
$post = Blog_Post::create()->find_by_url_title('my_first_post');
- list_recent_posts($count = 10, $show_future_posts = true) - returns recent published posts. You can specify a number of posts to return in the first method parameter. The second parameter allows to hide posts with future publish dates. Static method. Returns an instance of the Db_DataCollection class. Each element in the collection is an instance of the Blog_Post class. Example:
$post_list = Blog_Post::list_recent_posts();
Next: Blog_Category class
Previous: Blog API
Return to Blog API