Dries, you asked for this.

CommentFileSizeAuthor
#4 block_php_2.patch9.68 KBchx
#2 block_php_1.patch3.51 KBchx
#1 block_php_0.patch3.38 KBchx
block_php.patch3.37 KBchx
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

FileSize
3.38 KB

Escaped the < and > signs in the description.

chx’s picture

FileSize
3.51 KB

Rewording following advice from Steef and JonBob.

Dries’s picture

This looks _really_ handy to me. +1 from me.

In order not to confuse the average user, I suggest to remove the 'node-type specific visibility settings'. Like that, we cater for the most common/popupalar functionality. Anything less popular can be implemented using PHP.

This is a good example of 'less is more'.

chx’s picture

FileSize
9.68 KB

I deleted types.

budda’s picture

Probably a little confusing to non-coders but it will solve the problem and copy n paste code can be provided via drupal.org for users.

Good stuff.

+1 from me.

tostinni’s picture

Probably a little confusing to non-coders but it will solve the problem and copy n paste code can be provided via drupal.org for users.

Maybe a handbook page could be created with some examples Dries provided on the mailing list (and others code of course) and make a link in the block_help ?

Dries’s picture

Committed to HEAD.

Anonymous’s picture

m3avrck’s picture

Version: » 4.6.0

I know this closed and will be added to the handbook soon, but here are a few examples for anyone interested (I'm currently using these):

To display a block to any user that is logged in (hide from anonymous users):

<?php
global $user;
return ($user->uid > 0);
?>

And to display a block for only logged in users of a certain type:

<?php
global $user;
return (in_array('YOUR ROLE GOES HERE',$user->roles)); 
?>
rrichard63’s picture

Update #9 above appears to say this patch was incorporated into 4.6.0. But it appears to me to be gone from 4.6.3. Is this correct? If so, why was it dropped?

Also, just out of curiosity, why does this patch drop the "types" field from the "blocks" table?

Bob Richard

tostinni’s picture

In fact, it has been incorporated to HEAD aka 4.7 so it doesn't work in 4.6.x

Also, just out of curiosity, why does this patch drop the "types" field from the "blocks" table?

See what Dries mentioned in #3

shyam2053’s picture

Will this work in 4.6.x?

If not why? and how can it be made to work on 4.6.x?

puregin’s picture

Just to answer shyam2053's question - new features are added to the 'development' version, i.e. HEAD. Once a numbered release is made, e.g. 4.6, that becomes a branch, and no new development is done, on that branch, except for example to fix security issues.