API page: https://api.drupal.org/api/drupal/modules%21block%21block.api.php/functi...

How to set multiple pages using the 'pages' return value. i tried using as per documented, but in the admin panel it only results in 1 line where carriage return is visible as well. It isn't parsed.
So how do i go about setting multiple pages?

	$blocks['demotrisco2'] = array(
    'info' => 'demotrisco2',
	'region' => 'header',
	'visibility' => BLOCK_VISIBILITY_LISTED,
	'pages' => '<front>\ndemo/trisco/p/homepage/*',
	'status' => 1,
	'weight' => 3,
  );

I need it in my code so i can make fast new drupal deployments, not having to hassle with having to configure everything manually.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

FUNimations’s picture

Category: Bug report » Support request
jhodgdon’s picture

Status: Active » Fixed

In order for \n characters to work, you need to put your pages string in double quotes. In PHP (as well as many other programming languages), \n is a string escape character that does not work in single quotes.

jhodgdon’s picture

Category: Support request » Bug report
Status: Fixed » Active
Issue tags: +Novice

Hm. That said, the documentation has '\n' in single quotes, which isn't going to work. We should fix that. 7.x only -- hook_block_info() doesn't exist in 8.x.

FUNimations’s picture

Thank you. Using double quotes works.
Although i do feel this should be mentioned in the documentation.
As single quotes are pretty much the standard used in the example code.

jhodgdon’s picture

OK, please provide a patch. I already changed this to a documentation bug report. :)

Pol’s picture

Status: Active » Needs review
FileSize
1.05 KB

Here's a one line patch, I've also added an example.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

This simple change makes it a lot better.

jhodgdon’s picture

Status: Reviewed & tested by the community » Needs work

Thanks! One small thing, at the end:

  *     FALSE if the block should not be visible.
+ *     Example: "<front>\nnode/1"

This is part of the same paragraph above, so it should not start on a new line. We like all documentation lines to be wrapped as close to 80-character lines as possible. Also, this example comes after a long explanation of the option of providing PHP code, while it illustrates the set of paths option, so can the example be moved closer to the option it illustrates?

GoddamnNoise’s picture

Status: Needs work » Needs review
FileSize
1.48 KB

I've tried to fix that.

jhodgdon’s picture

Status: Needs review » Needs work

Thanks! The wrapping looks good, but most of the new docs lines end in spaces. Please remove them.

If you plan to work on Drupal patches (and I hope you do!), you might want to investigate your editor settings. Most code editors have a setting to either remove or highlight end-of-line spaces, and we never want them in Drupal code files.

Rajendar Reddy’s picture

Status: Needs work » Needs review
FileSize
1.47 KB

rerolling the patch.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, looks good!

  • Commit d2481b8 on 7.x by jhodgdon:
    Issue #2195357 by Rajendar Reddy, GoddamnNoise, Pol: Fix docs in...
jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Thanks again! Committed to 7.x.

GoddamnNoise’s picture

Thanks to you jhodgdon for all your help. I've already configured my editor settings to highlight those annoying end-of-line spaces. I've no much time, but I'd like to work on Drupal patches, and no documentation-related only as I'm a developer. Do you have any advice to put me on the right way ASAP?.

jhodgdon’s picture

Yes: my advice is to attend the Core Mentoring hours, and they can help you find appropriate issues to work on:
https://drupal.org/core-mentoring
You can also search the issue queue for issues tagged "Novice", or if you are interested in working on Drupal 8, the "Core" group on groups.drupal.org periodically has posts outlining tasks appropriate for new contributors:
https://groups.drupal.org/core

GoddamnNoise’s picture

And again... thanks A LOT, jhodgdon. I'll try to take your advices.

Status: Fixed » Closed (fixed)

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