0

I have created a custom region regions['my_region'] in mytheme.info file. I have added a block myblock to the region. Now how can I add contents to this block? Currently I have created a template file region--my_region.tpl.php and added contents there. Is this the right way? How can a normal user will be able to edit these contents?

1

2 Answers 2

1

There is simple method to add content in block.

  • Go to Administration -> Structure -> Block
  • click on 'Add Block' link in top of page.
  • Add content in 'body' section and assign the region for your theme in 'region settings' section in page and save the form.

Kindly see that only administrator or user which has access to edit block, can edit the block content.

As we can add multiple block in a region, so its not good solution to add content in region--my_region.tpl.php file. If you will add content in your region--my_region.tpl.php file, then you can set 'page visibility' condition for the block.

2

Blocks are considered configuration, not a content. Thus, there is no separate privilege you can give your "normal users" to allow them to edit blocks.

There is another way round. You can make some of content to be a blocks with Nodeblock or one of it's competitors:

This module allows you to specify content type(s) as being a block. This allows the content managers of the site to edit the block text and title without having to access the block administration page. Users only need edit access to that node in order to edit it.

That way you can create content type Block, and apply node permissions to it. All of them, including "edit own block" or "edit any block".

Just be sure no one have "delete" permissions on them, as it would remove block you placed from your page, and that should be admin-only task.


Other way is to use Views module. With Views, you can define a block and make it to show user's content, using various filters and orders. You could, for example, make a Views block that displays content of type news from users with role reporter, unless it's Friday in Iceland, and when it is, display content of type joke. Order by random, by date, by user's reputation, by anything you want :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.