Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comments
Comment #1
FUNimations CreditAttribution: FUNimations commentedComment #2
jhodgdonIn 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.
Comment #3
jhodgdonHm. 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.
Comment #4
FUNimations CreditAttribution: FUNimations commentedThank 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.
Comment #5
jhodgdonOK, please provide a patch. I already changed this to a documentation bug report. :)
Comment #6
PolHere's a one line patch, I've also added an example.
Comment #7
longwaveThis simple change makes it a lot better.
Comment #8
jhodgdonThanks! One small thing, at the end:
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?
Comment #9
GoddamnNoise CreditAttribution: GoddamnNoise commentedI've tried to fix that.
Comment #10
jhodgdonThanks! 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.
Comment #11
Rajendar Reddy CreditAttribution: Rajendar Reddy commentedrerolling the patch.
Comment #12
jhodgdonThanks, looks good!
Comment #14
jhodgdonThanks again! Committed to 7.x.
Comment #15
GoddamnNoise CreditAttribution: GoddamnNoise commentedThanks 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?.
Comment #16
jhodgdonYes: 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
Comment #17
GoddamnNoise CreditAttribution: GoddamnNoise commentedAnd again... thanks A LOT, jhodgdon. I'll try to take your advices.