block visibility through code

block visibility through code

by Rij Blr -
Number of replies: 1

Can I manage visibility of a custom block by wriiting custom code?

I will be writing a custom block that should be displayed under conditions, which will be evaluated through few lines of code.

Thanks,
RJ

Average of ratings: -
In reply to Rij Blr

Re: block visibility through code

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

In your block's get_content method, if that method returns no content, then the block will not appear. Several of the standard blocks do this so as to only appear in certain situations. The login block is one.