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.
this is my view file "form_setup_html.php".
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';
Viewing 15 lines of 47 lines. View entire code block.
this is my view file "form_setup_html.php".
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');