PHP code example of andremyid / post

1. Go to this page and download the library: Download andremyid/post library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

andremyid / post example snippets




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");
	// }

}



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);
	// }

}

    // 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);