Comments

jhodgdon’s picture

Issue tags: +Novice, +Needs backport to D7

Sounds like a good thing to document. Documentation of 'pages' should probably say that it can be a string with the paths, or PHP code, depending on the value of 'visibility'.

And while we're at it, this whole doc block's list formatting could be updated to current standards (not using '' around the array element names):
http://drupal.org/node/1354#lists

jmarkel’s picture

Status: Active » Needs review
StatusFileSize
new3.72 KB
new3.89 KB

I made the suggested changes (for 'pages' and for the array element names).

Here are two patches - one for 8.x and one for 7.x

It's my first core patch (doc or otherwise) - please be gentle with me :-)

Status: Needs review » Needs work

The last submitted patch, drupal-7.x-api-doc-1500160-1.patch, failed testing.

jmarkel’s picture

Guess I needed to open a separate issue for 7.x - will do so

jmarkel’s picture

Status: Needs work » Needs review
tstoeckler’s picture

That really pretty good, I think.
One thing that I think could be added, is the information that the custom PHP code should return TRUE or FALSE depending on whether the block should be shown.

jmarkel’s picture

Assigned: Unassigned » jmarkel

I'll make that change (for PHP code) and re-roll the patch.

I've also opened #1503614: Document the 'pages' key in hook_block_info() for the 7.x backport.

jmarkel’s picture

Assigned: jmarkel » Unassigned
StatusFileSize
new4.07 KB

Here's the update with the PHP code addition

jmarkel’s picture

StatusFileSize
new4.07 KB

Dang it. Typo - fixed

tstoeckler’s picture

Status: Needs review » Needs work
+++ b/core/modules/block/block.api.php
@@ -87,7 +87,13 @@
+ *     PHP code when 'visibility' is set to BLOCK_VISIBILITY_PHP. Note that ¶

Trailing whitespace.

Also, I just re-read the docs for drupal_match_path() and found:

String containing a set of patterns separated by \n, \r or \r\n.

So not only \n is supported. Should we document all three options?

jmarkel’s picture

Status: Needs work » Needs review
StatusFileSize
new4.08 KB

So we should :-)

jhodgdon’s picture

Status: Needs review » Needs work

The docs look good! A minor grammatical nitpick: "which" should be "that" (in "A string which contains one or...") (bonus points if you fix which/that in the text above too -- you use "which" only if it's after a comma).

Also, I think we should also document here that you can use * as a wildcard in the paths?

jmarkel’s picture

Status: Needs work » Needs review
StatusFileSize
new4.96 KB

It's a good nit to pick, though also one that I often ignore - but 'which' and 'that' do have different use cases, which are worth remembering.

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Awesome!
Setting to RTBC. This is on jhodgdon's plate, so if there's something wrong that I missed she can set it back to "needs work".

jhodgdon’s picture

Status: Reviewed & tested by the community » Needs work

Much better... Still a little concerned about wording:

...
+ *     PHP code when 'visibility' is set to BLOCK_VISIBILITY_PHP. Paths may
+ *     include the wildcard extension '*' (e.g. 'node/*' to designate
+ *     all pages having paths beginning with 'node/'), or '<front>' to
+ *     designate the site front-page. For BLOCK_VISIBILITY_PHP,
...

How about just this for that sentence:

Paths may use * as a wildcard (matching any number of characters); designates the site's front page.

jmarkel’s picture

Status: Needs work » Needs review
StatusFileSize
new4.89 KB

Gotcha. And done...

tstoeckler’s picture

Status: Needs review » Needs work

I re-read the whole patch and found some wrapping issues. :(
So sadly have to mark needs work again.

+++ b/core/modules/block/block.api.php
@@ -39,10 +39,10 @@
+ *   - cache: (optional) A bitmask describing what kind of caching is
  *     appropriate for the block. Drupal provides the following bitmask

I think this wraps early now. (I am always unsure about 80 vs. 81 chars, so this might be incorrect.)

+++ b/core/modules/block/block.api.php
@@ -56,27 +56,27 @@
+ *   - properties: (optional) Array of additional metadata to add to the
  *     block. Common properties include:
...
+ *     - administrative: Boolean that categorizes this block as usable in
+ *       an administrative context. This might include blocks that help an
...
+ *   - status: (optional) Initial value for block enabled status. (1 =
  *     enabled, 0 = disabled). An initial value for 'region' is required for
...
+ *   - region: (optional) Initial value for theme region within which this
  *     block is set. If the specified region is not available in a theme, the
...
+ *   - visibility: (optional) Initial value for the visibility flag, which
  *     tells how to interpret the 'pages' value. Possible values are:

@@ -87,7 +87,14 @@
+ *     PHP code when 'visibility' is set to BLOCK_VISIBILITY_PHP. Paths may
+ *     use '*' as a wildcard (matching any number of characters); '<front>'
+ *     designates the site's front page. For BLOCK_VISIBILITY_PHP,
+ *     the PHP code's return value should be TRUE if the block is to be made

These all wrap early.

jmarkel’s picture

Assigned: Unassigned » jmarkel

Why is wrapping < 80 a problem? No lines are > 80; neither are any abnormally short or broken at odd places.

jhodgdon’s picture

Everything should wrap as close to 80 characters as possible (including leading white space).
http://drupal.org/node/1354#general (last bullet point in that section)

jmarkel’s picture

StatusFileSize
new5.98 KB

Okay, thanks. Try this one - I think everything is wrapped as near to 80 as I could get it.

tstoeckler’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new5.97 KB
+++ b/core/modules/block/block.api.php
@@ -85,9 +85,16 @@
+ *     and any value provided can be modified by a user on the block ¶

Trailing whitespace.

Fixed that one myself. That is the only thing I changed, so I'll have the audacity to mark my own patch RTBC.

jmarkel’s picture

Grrr - annoys me that I missed that. Thanks, tstoeckler. This is good to go now, I trust :-)

jhodgdon’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed to 8.x. Thanks!!

Apparently needs to be rerolled before it will apply to 7.x.

jmarkel’s picture

No prob - will do it later on today.

jmarkel’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new6.63 KB

re-rolled for 7.x

rmalcome’s picture

Assigned: jmarkel » rmalcome
rmalcome’s picture

Status: Needs review » Reviewed & tested by the community

RTBC at 3/28 Long beach Drupal LA meetup
works well

rmalcome’s picture

Assigned: rmalcome » Unassigned
jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Thanks - committed to 7.x.

tstoeckler’s picture

Issue tags: +Needs backport to D6

Well I guess this should be backported to D6 as well.
The code is a little different, but basically the same:
http://api.drupal.org/api/drupal/developer!hooks!core.php/function/hook_...
I don't know if it's worth it, though (since hooks aren't documented in-code in D6), so leaving at fixed.

tstoeckler’s picture

Status: Fixed » Needs work

Just realized my post was a little schizophrenic.
So marking needs work.
If you don't think this is worth it, feel free to revert to fixed.

jhodgdon’s picture

Project: Drupal core » Documentation
Version: 7.x-dev »
Component: documentation » API documentation files
Status: Needs work » Patch (to be ported)

The docs are in code in D6, just not in Drupal Core. Moving to Documentation project (that is where the files are, in the Documentation project git repo, under developer/hooks). Patch welcome. :)

jmarkel’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new1.2 KB

Here's a patch for 6.x. I only made the changes to document 'pages.' I made no attempt to backport the other changes in 7.x and 8.x

jhodgdon’s picture

Status: Needs review » Needs work

The indentation is not correct there, but other than that it looks fine, and I agree with the idea of only fixing the 'pages' documentation.

jmarkel’s picture

StatusFileSize
new1.21 KB

When you're right, you're right.
Here's another patch...

jmarkel’s picture

Status: Needs work » Needs review
tstoeckler’s picture

Status: Needs review » Needs work
+++ b/developer/hooks/core.php
@@ -187,7 +187,13 @@ function hook_action_info_alter(&$actions) {
+ *       2, the PHPcode's return value should be TRUE if the block is to be made

PHPcode -> PHP code

Otherwise RTBC

jmarkel’s picture

Status: Needs work » Needs review
StatusFileSize
new1.21 KB
tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

RTBC, me thinks. Awesome!

kristen pol’s picture

Status: Reviewed & tested by the community » Active

I read through the documentation in #38 (for 'pages') and it is clear to me but I don't know where to apply the patch.

kristen pol’s picture

Status: Active » Reviewed & tested by the community

Didn't mean to put it back to active.

jmarkel’s picture

It took me a little while to find it - it's part of the Documentation project

jhodgdon’s picture

Project: Documentation » Drupal core
Version: » 7.x-dev
Component: API documentation files » documentation
Status: Reviewed & tested by the community » Fixed

Yes, Documentation project (hence why this issue was moved to that project. :) ).

Thanks! I've committed this to the D6 docs project. Moving issue back to core for posterity.

Automatically closed -- issue fixed for 2 weeks with no activity.