andremyid/post
Composer 安装命令:
composer require andremyid/post
包简介
The Andremyid Post package.
关键字:
README 文档
README
The Andremyid Post package.
Installation
- Add the following to your
Composer JSONfile
"andremyid/post": "~0.0"
- Run Composer
$ composer update
- Add the following to 'Andremyid/Framework-Core' => 'ServiceProvider'
Andremyid\Post\PostServiceProvider
- Run the migration
You can use database from WordPress, or copy from sample database migrate manually (you can modify as you like of the sample)
// first, optional
$ composer dump-autoload
// and then
$ php andre migrate
Usage
Extending
- Sample Backend Page
<?php use Andremyid\Post\SampleBackendPage; use Andremyid\Post\BackendPageTrait; class YourControllerBackendName extends SampleBackendPage { use BackendPageTrait; public function post_index() { return $this->index(); // use sample backend page } // uncomment below to replace sample backend page // protected funtion index() // { // return $this->viewModule($this->module, "Title Backend Module"); // } }
- Sample Frontend Page
<?php use Andremyid\Post\SampleFrontendPage; use Andremyid\Post\FrontendPageTrait; class YourControllerFrontendName extends SampleFrontendPage { use FrontendPageTrait; public function post_index() { return $this->index(); // use sample frontend page } // uncomment below to replace sample frontend page // protected funtion index() // { // $post = Post::model()->ofPublish(); // return $this->view($this->themes . 'index' , $post); // } }
Model
Posts Table
Post::model();to call back new Model Post (wp_posts)Post::findSlug('sample-post-name')return array data from query wherewp_posts.post_name = $slugPost::find($id);to getwp_postswhereid = $idPost::create($data);to createwp_posts
// sample create post manually Post::setCategory(array('uncategorized'); Post::setStatus('publish'); // auto-draft, inherit, publish Post::setType('post'); // default 'post' $data = array( 'post_author' => $user_id, 'post_content' => 'Sample Content', 'post_title' => 'Sample Title', 'post_name' => Post::makeSlug('Sample Title'), ); Post::create($data);
Post::update($id);to updatewp_postwhereid = $idPost::delete($id);to deletewp_postwhereid = $id
Terms Table
Term::model();to call back new Model Term (wp_terms)Term::findSlug('sample-slug')return data from query wherewp_terms.name = $slugTerm::find($id);to getwp_termswhereterm_id = $idTerm::create($data);to createwp_termsTerm::update($id);to updatewp_termswhereid = $idTerm::delete($id);to deletewp_termswhereid = $id
Credits
It's inspired by WordPress
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Project
- 更新时间: 2016-06-01