This is a small module that adds a new block "Facebook comments" with a facebook comments plugin configuration, this block will load the facebook comments widget for the current page being displayed in using the real path URL instead of path aliases or clean URLs.
Some similar modules are using the URL alias which will make you lose the old comments in case you decided to change the URL aliases.
Sandbox
Link : https://www.drupal.org/sandbox/mqanneh/2441099
Git repo
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/mqanneh/2441099.git facebook_comments_block
Reviews of other projects
Comment | File | Size | Author |
---|---|---|---|
#3 | Facebook_Comments.png | 40.97 KB | mqanneh |
Comments
Comment #1
mqannehComment #2
mqannehComment #3
mqannehComment #4
alaa abbad CreditAttribution: alaa abbad commented+1
Comment #5
mqanneh+1
Comment #6
mvdve CreditAttribution: mvdve commentedI did a code review and run an automated test.
The automated test shows some code standards issues.
Take a look at the report.
A suggestion would be to use the theme function with a template file for your HTML markup and pass the variables to it.
This way, users can easily edit the markup of the module when needed and it is better to split the logic and markup.
Comment #7
mqannehThank you @mvdev, I fixed my code based on Drupal Coding Standards, you can check the new report from Here.
I'm currently working on the theme function for the HTML.
Comment #8
mqannehAdded theme function with a template file + preprocess template function to prepare variables
Comment #9
mqannehAdded theme function with a template file + preprocess template function to prepare variables
Comment #10
mqannehComment #11
mvdve CreditAttribution: mvdve commentedThe function of the template file is to create a file with mainly HTML and to split the smart functionality from basic HTML markup.
Take a look at for example the page.tpl.php file from Drupal. You don't have to use print as the file is rendered in the theme function.
Also it is better to pass the variables to the theme function and not via a preprocess functions.
See the examples of hook_theme.
Not related to this module but to get a review bonus, you have to manually review a module. The one you have added to the issue summery was already fixed so it didn't need a review anymore.
Comment #12
mqannehUpdated template file
Comment #13
urashima82 CreditAttribution: urashima82 commentedHello @mqanneh,
Here is my manual review :
As mentionned by @mvdve, you should send vars to your template through the theme() function, and change the hook_theme() like this :
You can delete the template_preprocess_facebook_comments_block() function, it will be useless with the code above.
Then, you have to change your template file like this to make it more readable :
That's all for me, I hope it will help you :)
Regards.
Comment #14
urashima82 CreditAttribution: urashima82 commentedYou also need to change this :
Comment #15
mqanneh@urashima82
fixed everything regarding your last comment, kindly check again
Comment #16
mqannehComment #17
mqannehComment #18
urashima82 CreditAttribution: urashima82 commentedHello,
I've checked your code and everything seems to be good for me.
Regards.
Comment #19
mvdve CreditAttribution: mvdve commentedChecked the code and looks good.
Can you describe what the difference is between you module and these two:
Facebook Comments Social Plugin
Facebook Comments Box
Comment #20
mqanneh@mvdve
these two modules have a complex configuration and send the url-alias to facebook (data-url) instead of the node id.
in case you changed the URL aliases pattern you will lose previous comments.
Comment #21
aneek CreditAttribution: aneek commentedHello
It's a good small but nice useful module. I enabled it and tested it. However, the following I found while doing a manual review.
hook_block_save()
code. But the thing is if someone disables and uninstalls your module those variable will still persist in the database variable table. So, it's always better to add a.install
file and usehook_install()
&hook_uninstall()
to set and delete variables initially while module is enabled or uninstalled respectively.Variables:
I hope these make sense. Please let me know if you have any queries.
Thanks!
Comment #22
aneek CreditAttribution: aneek commentedComment #23
mqanneh@aneek
I added .install file to set initial variables values on install and to remove these variables on uninstall.
because my module defines a new block I added
at enabling/disabling module.
I postponed the javascript file as I'm currently working on an enhancement to the module FB script loading.
the module will load the fb script in the current user language dynamically.
can you check the module again.
Comment #24
mqannehSeparated javascript code from the template file.
added new file for js code.
passed variables from php to js via Drupal.settings.
Comment #25
mqannehComment #26
mqannehComment #27
mqannehComment #28
mqannehComment #29
mqannehComment #30
urashima82 CreditAttribution: urashima82 commentedHello,
I've tested your module, it's always good.
I suggest you a little improvement in your array declarations:
Just tell me when you're done and I'm gonna revalidated your module.
Regards.
Comment #31
mqanneh@urashima82
that's a good idea.
Done
Comment #32
urashima82 CreditAttribution: urashima82 commentedThanks, the module is ok for me :)
Comment #33
mqannehComment #34
aneek CreditAttribution: aneek commented@mqanneh, nice changes. RTBC++
Comment #35
mqannehthanks @aneek for reviewing my module
Comment #36
kala4ekHi @mqanneh, I make some short code review, but I have found just minor notices:
facebook_comments_block.js
Is it really needed to don't use drupal js behavior system?
Will it works with blocks loaded by ajax?
facebook_comments_block.install
facebook_comments_block.module
Also, looks like project page is a bit short, please follow the instructions at https://www.drupal.org/node/997024 page.
Comment #37
naveenvalechaAssigning to myself for next review that may be tonight.
Comment #38
mqanneh@naveenvalecha, done with all notes mentioned by @kala4ek in comment #36.
Comment #39
m.abdulqader CreditAttribution: m.abdulqader commented+1
Comment #40
naveenvalechaReview of the 7.x-1.x branch (commit b0e5661):
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
Manual Review :
Rest seems good to me.No blocker found.
Assigning to mpdonadio to take a final look if he has time.
Comment #41
mqannehComment #42
abhiklpm CreditAttribution: abhiklpm commented@mqanneh, a suggestion: you have used drupal_add_js() it wont work always.
We need to use #attached property to attach the assets
in a cache-friendly way. In D8 drupal_add_css(), drupal_add_js() and drupal_add_library()
are removed in favor of #attached, details here.
Below is the modified code, review it:
@mpdonadio correct me if I am wrong.
Comment #43
mqannehComment #44
abhiklpm CreditAttribution: abhiklpm commentedSorry I accidentally removed issue summary.
Comment #45
mqannehComment #46
mqanneh@naveenvalecha,
thank for your comments, I made some code modifications:
- added configure link of block in the facebook_comments_block.info file.
- added hook_help().
- removed clearing the cache upon module enable, disable, install and uninstall.
- updated README.txt file.
Comment #47
mpdonadioAutomated Review
Review of the 7.x-1.x branch (commit f307b99):
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
Manual Review
(+) Your behavior should use the context and settings that have been passed in. It also needs .once() functionality to make sure it doesn't get called during AJAX.
$form['facebook_comments_settings']['facebook_comments_block_settings_width'] should have a validator on it. See element_validate_integer_positive
Avoid global $base_url. Use the API, `$url = url(current_path(), array('absolute' => TRUE));` should work.
(+) facebook_comments_block_block_view() shouldn't returned themed output. It should return a render array with the theme elements in it.
(+) Avoid drupal_add_js(); use #attached in the render array.
(+) facebook_comments_block_block_info() will need to define DRUPAL_CACHE_PER_PAGE as the block will vary page to page.
The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
This review uses the Project Application Review Template.
Comment #48
mpdonadioThanks for your contribution, mqanneh!
I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.