[Extension] Bbii Forum

Thanks.

Btw, if you are the owner of the forum I think you are, you will be interested in this neat little adjustment of the pager that will be included in version 1.0.8: http://www.doprogramsdream.nl/blog/blogPost/view/id/20.

Thank U. I already did that before)

And I did so in the file _topic.php (could not do this with Yii)

this


$postsPerPage

$active

$count_show_page

$url

$url_page

customized for you

How it works, see the picture




 <?php

/* input data */

  $n=$data->num_replies;

  $postsPerPage = 15;

  $count_pages = ceil($n / $postsPerPage);

  $active = 0;

  $count_show_pages = 3;

  $url =  'topic?id='.$data->id;

  $url_page =  'topic?id='.$data->id.'&BbiiPost_page=';

  if ($count_pages > 1) {

    $left = $active - 1;

    $right = $count_pages - $active;

	

    if ($left < floor($count_show_pages / 2)) $start = 1;    

    else $start = $active - floor($count_show_pages / 2);

    $end = $start + $count_show_pages - 1;

    if ($end > $count_pages) {

      $start -= ($end - $count_pages);

      $end = $count_pages;

     $start = 1;

    }

?>

      <!-- start Pagination -->

      <div class="pagination">

        <?php for ($i = $start; $i <= $end; $i++) { ?>

        <div id="pagin"><a href="<?php if ($i == 1) { ?><?=$url?><?php } else { ?><?=$url_page.$i?><?php } ?>"title="<?=$text?>. Cтраница <?=$i?>">

        <?=$i?></a></div>

        <?php } ?>

        <?php if ($count_show_pages < $count_pages) { ?>

       <div id="pagin"><a href="<?=$url_page.$count_pages?>" title="<?=$text?>. Page <?=$count_pages?> ">...

        <?=$count_pages?>

        →</a></div>

        <?php } ?>

      </div>

      <?php } ?>

    </div>

    <!-- end Pagination --> 

    

  </div>

  <div class="forum-cell center">

   ...........

Refresh in post page not work correct with paginator ( in page 2,3… etc). After refresh any page paginator go to page 1.

Fix - in file ForumController.php


......} elseif(!$this->isModerator()) {

				$groupId = BbiiMember::model()->findByPk(Yii::app()->user->id)->group_id;

				if($forum->membergroup_id != $groupId) {

					throw new CHttpException(403, Yii::t('BbiiModule.bbii', 'You have no permission to read requested topic.'));

				}

			}

		}

		$dataProvider=new CActiveDataProvider('BbiiPost', array(

			'criteria'=>array(

				'condition'=>'approved = 1 and topic_id=' . $topic->id,

				'order'=>'t.id',

				'with'=>array('poster'),

			),

			'pagination'=>array(

				'pageSize'=>$this->module->postsPerPage,

			),

		));



exchange code


......} elseif(!$this->isModerator()) {

				$groupId = BbiiMember::model()->findByPk(Yii::app()->user->id)->group_id;

				if($forum->membergroup_id != $groupId) {

					throw new CHttpException(403, Yii::t('BbiiModule.bbii', 'You have no permission to read requested topic.'));

				}

			}

		}

		if(isset($_GET['BbiiPost_page']) && isset($_GET['ajax'])) {

            $postPage = (int) $_GET['BbiiPost_page'] - 1;

            Yii::app()->user->setState('BbiiPost_page', $postPage);

			Yii::app()->user->setState('BbiiTopic_id', $id);

            unset($_GET['BbiiPost_page']);

        } elseif(isset($_GET['ajax'])) {

            Yii::app()->user->setState('BbiiPost_page', 0);

		} elseif(Yii::app()->user->hasState('BbiiTopic_id') && Yii::app()->user->BbiiTopic_id != $id) {

			unset(Yii::app()->user->BbiiTopic_id);

			Yii::app()->user->setState('BbiiPost_page', 0);

		}

		

		$dataProvider=new CActiveDataProvider('BbiiPost', array(

			'criteria'=>array(

				'condition'=>'approved = 1 and topic_id=' . $topic->id,

				'order'=>'t.id',

				'with'=>array('poster'),

			),

			'pagination'=>array(

				'pageSize'=>$this->module->postsPerPage,

				'currentPage' => Yii::app()->user->getState('BbiiPost_page', 0),

				

			),

		));

for after pagination to get top of the page

add in file topic.php this


'afterAjaxUpdate' => 'function(){

$("html, body").animate({scrollTop: $("body").position().top }, 100);}',

after


<?php $this->widget('zii.widgets.CListView', array(

		'id'=>'bbiiPost',

		'dataProvider'=>$dataProvider,

		'itemView'=>'_post',

I’m sorry I do not speak English and I use Google translator :rolleyes:

Something along those line would be a good idea.

how to create polls with options

Create a new topic and click the Add poll button.

add poll button not apear

In that case you have configured that forum not to allow polls. Change the Poll setting for the Forum in which you want to allow the creation of polls. Read the manual when you do not know how to do that.

ok thanks

Еmail subscription it’s great! thank you!

I need wait 1.0.9?

Still doing some testing. Probably in a week or so.

Еmail subscription work excellent!

thank you so much!

in attach file russian translation for 1.0.9

This extension work with Yii2 advanced???

Ronald, how to do that - when you create a new topic, the author was already subscribed to it?

I tried to add an event to the save button in the file create.php but I did not succeed. Help me please

Below is an example from the ForumController.php




	$object = new BbiiTopicsRead;

	$model = BbiiTopicRead::model()->findByPk(Yii::app()->user->id);

	if($model === null) {

		$model = new BbiiTopicRead;

		$model->user_id = Yii::app()->user->id;

	} else {

		$object->unserialize($model->data);

	}

	$object->setFollow($_POST['topicId'], $_POST['postId']);

	$model->data = $object->serialize();

	$model->save();

What the code does is read the serialized data for the current user from the table bbii_topic_read.

This data is passed to an object of the class BbiiTopicsRead (notice the ‘s’ in there) via the unserialize method.

What you will need to change is the parameters passed to the object function setFollow().

These will need to be the topic id and the post id of the topic and post just created by the user.

Finally the serialized data needs to be passed back to the data field and saved.

No, but I know that Stefano Mtangoo has made a forum module that works for Yii2. As far as I know he has not published the code, I do not even know whether he plans to do so, but you may ask him about it.

thank you! it’s work great!

Hi,

I had plan to release it but not under current code conditions. There are some cleaning need to be done and I have no time to do it myself.

So until I find time or another one does it, It will remain closed source.

And Yes, it runs fine under Yii2 see my signature below!

Hello Ronald.

In file vote.php

in line error


echo CHtml::button(Yii::t('bbii', 'Vote'), array(....

correct attribute


echo CHtml::button(Yii::t('BbiiModule.bbii', 'Vote'), array(....