Create a package with single pages and blocks.

Permalink
I am create a package with single pages. Single pages is working and this is only for admin. Admin will add details and set setting from admin area. Now i want to fetch all those values from admin to block section, My block is created but unable to fetch data from database. Please help me.

In block section there is one controller file. In this controller file on there is view() method defined. I have add my db query there and set value in a variable, but this variable value not getting values on block page.

Please let me know how i do this.

This is my controller file.
<?php    
namespace Concrete\Package\packagename\Block\packagename;
use Page;
use Concrete\Core\Block\BlockController;
use Core;
class Controller extends BlockController
{
    protected $btTable = 'tablename';
    protected $btInterfaceWidth = "520";
    protected $btInterfaceHeight = "780";
    protected $btCacheBlockRecord = true;
    protected $btCacheBlockOutput = true;
    protected $btCacheBlockOutputOnPost = true;
    protected $btCacheBlockOutputForRegisteredUsers = false;
    protected $btDefaultSet = 'multimedia';


this is my view file "form_setup_html.php".

<?php     defined('C5_EXECUTE') or die("Access Denied."); 
   print_r($apikey);
?>
<table>
   <tbody>
      <tr>
         <td>Select Category</td>
         <td>
            <select name="cat_id">
               <option value=""></option>
            </select>
         </td>
      </tr>
   </tbody>
</table>

 
hutman replied on at Permalink Reply
hutman
I'm going to try to help here, but I feel like there is a lot of information missing in this post that could be important, so I appologize if I point out something that doesn't make sense.

1) Your namespace needs to be namespace Concrete\Package\packagename\Block\blockname;

2) You're missing the use Database; statement at the top of your file.

3) Your protected $btTable = 'tablename'; needs to be set to the same table name that you're using in your db.xml, this is the table that stores the block record

4) Assuming that you're not manually stuffing records into your block table (which you should not be doing) this line doesn't make much sends as the tablename should be different than the table record. $r = $db->GetAll('SELECT * from tablename WHERE status = 1 ORDER BY id DESC');
priteshmahajan replied on at Permalink Reply
Thank you for your reply