Accessing block database columns from PHP script in "tools" directory
Permalink 1 user found helpful
Hi,
This is I guess is a fairly basic question but I have not found any documentation or examples showing how to solve it. I'm trying to develop a fairly basic new block type, and I'm having trouble accessing the block database columns (i.e. the block "configuration" info) from a PHP file in the tools directory. What is the recommended way of doing this?
Background:
I have in my db.xml defined a couple of database fields for my block. As described in the "creating a new block type" how-to "In our typical block controller, the value of the database columns are automatically extracted and placed in the local scope.". So from for example my view.php file in the root directory of my block I can easily access the database columns with something like "$column_name".
When I then wanna make my data requests asynchronous I have moved the database connectivity into a separate PHP file, which I put into my "tools" block directory (please correct me if this is not the recommended way of doing this). And now I can no longer access the database columns using a simple variable matching the column name.
What is the recommended way of accessing these columns from a PHP script in the blocks "tools" directory?
Thanks,
Alexander
This is I guess is a fairly basic question but I have not found any documentation or examples showing how to solve it. I'm trying to develop a fairly basic new block type, and I'm having trouble accessing the block database columns (i.e. the block "configuration" info) from a PHP file in the tools directory. What is the recommended way of doing this?
Background:
I have in my db.xml defined a couple of database fields for my block. As described in the "creating a new block type" how-to "In our typical block controller, the value of the database columns are automatically extracted and placed in the local scope.". So from for example my view.php file in the root directory of my block I can easily access the database columns with something like "$column_name".
When I then wanna make my data requests asynchronous I have moved the database connectivity into a separate PHP file, which I put into my "tools" block directory (please correct me if this is not the recommended way of doing this). And now I can no longer access the database columns using a simple variable matching the column name.
What is the recommended way of accessing these columns from a PHP script in the blocks "tools" directory?
Thanks,
Alexander
Here's what the tools file code might look like: