PostController::index PHP Method

index() public method

General "post" form, allows posting of any kind of form. Attach to PostController_AfterFormCollection_Handler.
Since: 2.0.0
public index ( $CurrentFormName = 'discussion' )
    public function index($CurrentFormName = 'discussion')
    {
        $this->addJsFile('jquery.autosize.min.js');
        $this->addJsFile('autosave.js');
        $this->addJsFile('post.js');
        $this->setData('CurrentFormName', $CurrentFormName);
        $Forms = array();
        $Forms[] = array('Name' => 'Discussion', 'Label' => sprite('SpNewDiscussion') . t('New Discussion'), 'Url' => 'vanilla/post/discussion');
        /*
        $Forms[] = array('Name' => 'Question', 'Label' => sprite('SpAskQuestion').t('Ask Question'), 'Url' => 'vanilla/post/discussion');
        $Forms[] = array('Name' => 'Poll', 'Label' => sprite('SpNewPoll').t('New Poll'), 'Url' => 'activity');
        */
        $this->setData('Forms', $Forms);
        $this->fireEvent('AfterForms');
        $this->setData('Breadcrumbs', array(array('Name' => t('Post'), 'Url' => '/post')));
        $this->render();
    }

Usage Example

Example #1
0
require_once 'app/db/doConnection.php';
?>

<!DOCTYPE html>
<html>
  <head>
    <title>The social network</title>
    <link type="text/css" rel="stylesheet" href="/assets/css/base.css" media="all" />
  </head>
  <body>
    <?php 
// Include the PostController
require_once 'app/controllers/PostController.php';
// Get the posts for current user based on the role.
$post = new PostController();
$results = $post->index();
?>

    <div id="main-wrapp">
      <header>
        <div class="logo"><a href="/">The Social Network</a></div>
        <div class="user-data">
          <p>Welcome USER!</p>
          <a href="/post_add.php">Add new post</a>
        </div>
      </header>

      <div class="main-container">
        <?php 
if (empty($results)) {
    ?>
All Usage Examples Of PostController::index