Block for static DB data display
Permalink
I'm create a block to fixed display Prayer Times. Basically, it's a table of all year days, and months with fixed times for daily prayers.
Data is something like:
The display will be a simple table, with the name of prayer and its time:
As I understood from the documentation, there needs to be a btID field for every block, but here it's fixed data for display only.
Am I doing the right thing, or do I have to create is in some other way?
Data is something like:
MONTH|DAY| P1 | P2 | P3 | P4 | P5 | ---------------------------------------- 1 | 1 |05:18|12:02|15:14|17:58|19:49| 1 | 2 |05:17|12:01|15:12|17:56|19:48| 1 | 3 |05:15|12:00|15:12|17:54|19:46| 1 | 4 |05:14|11:59|15:11|17:53|19:45| 1 | 5 |05:11|11:58|15:11|17:51|19:44|
The display will be a simple table, with the name of prayer and its time:
Today's Prayers |----------------| | Fajr | 05:18 | |----------------| | Dhohr | 12:02 | |----------------| | Asr | 15:14 | |----------------| | Magrib | 17:58 | |----------------| | Ishaa' | 19:49 | |----------------|
As I understood from the documentation, there needs to be a btID field for every block, but here it's fixed data for display only.
Am I doing the right thing, or do I have to create is in some other way?
Sorry, I didn't explain clearly what I'm doing.
I managed to create the block, while manually adding a table that contains my static date.
I simply defined my block table to be:
to allow the user to add a title for the block. Then, I manually created a table to hold my static timing data, connect to it, and display the information for today.
Here is my view:
So, I've got it done this way.
To finish add, I need to automatically create the data table and insert its data during the installation of the block. Shall I just override the install() method of the block's controller.php and insert the data? or is there another way?
I managed to create the block, while manually adding a table that contains my static date.
I simply defined my block table to be:
<?xml version="1.0"?> <schema version="0.3"> <table name="btKuwaitPrayerTimes"> <field name="bID" type="I"> <key /> <unsigned /> </field> <field name="title" type="C" size="255"/> </table> </schema>
to allow the user to add a title for the block. Then, I manually created a table to hold my static timing data, connect to it, and display the information for today.
Here is my view:
So, I've got it done this way.
To finish add, I need to automatically create the data table and insert its data during the installation of the block. Shall I just override the install() method of the block's controller.php and insert the data? or is there another way?
I would use install..
But don't forget bID! Your select stmt doesn't contain bID in the "where"
But don't forget bID! Your select stmt doesn't contain bID in the "where"
Absolutely. I'll clean it up, add some more options to display more information, maybe themes and finish it up tomorrow.
Thanks!
Thanks!
Since all prayer times data is fixed, I simply created an array out of the DB with the times.
Added two options, one for showing a title and one to show/hide the clock.
It was a nice and easy (relatively) experience creating a block.
I made the block translatable as well, with Arabic translation embedded.
Attached for any one's use:
messages.po for your language
kuwait_prayer_times.zip is the block package.
Added two options, one for showing a title and one to show/hide the clock.
It was a nice and easy (relatively) experience creating a block.
I made the block translatable as well, with Arabic translation embedded.
Attached for any one's use:
messages.po for your language
kuwait_prayer_times.zip is the block package.
Since blocks contain the content, c5 creates a new bID if you create a new page version and duplicates the old content...
I strongly recommend to use the bID. Don't try to avoid it. It might take a minute or two more time to build a block but it's worth the effort and once you are used to it, it's quite simple to use as well...