定制 andremyid/post 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

andremyid/post

Composer 安装命令:

composer require andremyid/post

包简介

The Andremyid Post package.

README 文档

README

The Andremyid Post package.

Installation

  • Add the following to your Composer JSON file
"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 where wp_posts.post_name = $slug
  • Post::find($id); to get wp_posts where id = $id
  • Post::create($data); to create wp_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 update wp_post where id = $id
  • Post::delete($id); to delete wp_post where id = $id

Terms Table

  • Term::model(); to call back new Model Term (wp_terms)
  • Term::findSlug('sample-slug') return data from query where wp_terms.name = $slug
  • Term::find($id); to get wp_terms where term_id = $id
  • Term::create($data); to create wp_terms
  • Term::update($id); to update wp_terms where id = $id
  • Term::delete($id); to delete wp_terms where id = $id

Credits

It's inspired by WordPress

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Project
  • 更新时间: 2016-06-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固