This module creates a block which displays the current (based on the regional settings) date/time. It allows a designated user to adjust the format of the date/time display using standard PHP date formatting. Although this current functionality is already available using other means (Example: create a block that allows PHP and display the date), this provides a simple interface for beginner users and doesn't require the PHP filter to be turned on. I am not aware of any other modules that perform this exact functionality.
Project Page: https://drupal.org/sandbox/flexman/2141203
GIT Repository: git clone --branch 7.x-1.x http://git.drupal.org/sandbox/flexman/2141203.git date_block
This is the first project that I have completed. Thank you.
Comments
Comment #1
PA robot commentedWe are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #2
prateekjain commentedModule works fine, block gets created and date is shown on enabling the block.
In the settings at admin/config/date_block, if the textfield is left empty and saved, no date is shown in the block which is right according to the code. It might be good to show a date with default format or put a check that empty value is not supported. Just a suggestion.
There is no version branch in git. Please follow the instructions related to git structure from here - https://drupal.org/node/1127732 and to set a default branch https://drupal.org/node/1659588
Comment #3
flexman commentedThanks for the suggestions - very valid, I just overlooked these items.
I have now made the admin settings field required. I have also added a default value in the code (somewhat redundant to add both features but you can never be too safe I suppose).
Also, working on branch 7.x-1.x now. Thanks for the tip.
Comment #4
swim commentedHey Flexman,
data_block.install, line 22.
Don't use db_query for running delete queries; instead use https://api.drupal.org/api/drupal/includes!database!database.inc/functio...
date_block.module, line 82.
hook_block_view will only invoke blocks defined by your module. This means unless you're going to add more blocks you don't need to perform a switch statement.
For a block focused module I wouldn't implement a menu hook & separate form to store the block settings. This creates confusion. Instead have a look at https://api.drupal.org/api/drupal/modules!block!block.api.php/function/h... &
https://api.drupal.org/api/drupal/modules!block!block.api.php/function/h...
Both of the above hooks are much more suited to your module.
Just a suggestion but I wouldn't worry about including a hook_install. Set your default value where you first implement date_block_default_format, which would be in the setting form in this case.
Cheers,
Comment #5
drupaldev@assyst commentedGetting some fatal errors using the git repository path provided. Use
git clone --branch master http://git.drupal.org/sandbox/flexman/2141203.git date_block
Comment #6
flexman commentedComment #7
flexman commentedAh shoot,
I forgot to update the GIT Repository to the latest 7.x-1.x version. I've updated it in the issue description now.
git clone --branch 7.x-1.x flexman@git.drupal.org:sandbox/flexman/2141203.git
Comment #8
drupaldev@assyst commentedYou should change the URL to clone the project to
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/flexman/2141203.git date_block
Your URL is for the maintainer.
Manual Review:
date_block.install line #22
Use variable_del() function to remove variable on uninstall hook would be ideal. So replace
db_query("DELETE FROM {variable} WHERE name LIKE 'date_block_%'");with
variable_del('date_block_default_format');date_block.module line #98
It would be good, if you can use Ternary Operator instead of if/else.
So replace below code in _date_block_content() function
with
Comment #9
flexman commentedComment #10
flexman commentedSeveral changes made, including:
Thanks.
Comment #11
boyan.borisov commentedHi flexman,
Congrats for the small and tidy module :) See below my comments:
- you should use format_date() Drupal core function instead of date(). format_date takes in consideration the site timezone and the current language. It's a drupal way to format dates.
- it's a recommended to use $delta in the hook_block_configure - see the example hook_block_configure
- have you try to find other modules which could achieve the same functionality? Drupal community encourages collaboration over competition. What are the benefits of your project compared with clock project?
- also I've seen the core reviewers to reject projects with less than 200 rows of code...
Comment #12
flexman commentedWell then...
I thought I had searched for similar modules, I somehow missed the "clock" module. You are right, it performs the exact same functionality (and more).
... on to the next module I guess.
Thanks everyone for the valuable feedback!