We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

make counter work in view page | Forum

Ken
Ken Oct 29 '20

    public function playCount() {
  
        $itemId = $_GET['id'];
        $viewCount = PLUGINS _BOL_Service::getInstance()->increasePlayCount( $itemId );

        exit(json_encode(array('id' => $itemId, 'count' => $playCount)));
  

}
The counter Increase works in list page but Only shows in view page doesn’t increase count can someone tell me why please.....
The Forum post is edited by Ken Oct 29 '20
dave Team
dave Oct 31 '20

Whatever you are counting should be +1


in other words


$val = 0;

$val = $val +1;


then it will increment by 1 each loop.  I dont know what that function does.  But  if the count is stored in the db thats fine, if not then youll either need to create a table to store it in or use $_SESSION variable to store it per visit or maybe with a cookie.  But db is better depending on what your doing.



Ken
Ken Nov 1 '20
Dave yours worked but the views wouldn’t save and wouldn’t increase after 1 but I accidentally figured it out using 


     $playCount = $playCount ++;

        PLUGIN_BOL_ItemDao::getInstance()->save($item);

        return $item->playCount;

         $itemId = $_GET['id'];

dave Team
dave Nov 2 '20
great glad you got it sorted..