diff options
Diffstat (limited to 'modules/block.module')
-rw-r--r-- | modules/block.module | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/modules/block.module b/modules/block.module index c70f0f6c5..bd5a3785c 100644 --- a/modules/block.module +++ b/modules/block.module @@ -2,40 +2,36 @@ // $Id$ function block_help() { - ?> - <p>Blocks are the boxes visible in the side bars on the left- and right-hand side of the website. They are either exported by the engine or by any of the active modules. To really get your teeth into a Drupal website, you are going to have to deal with blocks and administering blocks in a fairly sophisticated fashion. This means you will need to understand how the block placement strategy works.</p> - <p>The placement of blocks is delegated to the administrator. In most cases (i.e., the "custom" blocks), the user has complete control -- using preferences -- over whether or not they are enabled.</p> - <p>An administrator can lay out and arrange the available blocks to fit in two regions: "left" and "right". Regions simply contain blocks. In addition, an administrator can assign each block (within a region) a weight to sort them vertically. The heavier blocks will sink and the lighter blocks will be positioned nearer the top.</p> - <p>As mentioned, blocks may be arranged to fit in two regions: left and right. For theme builders, each region is identified by a corresponding constant: "left" and "right".</p> - <p>The path setting lets you define which pages you want the specific blocks to be shown. If you leave the path blank it will show on all pages. The path uses a regular expression syntax so remember to escape special characters!<br />Examples: - <ul><li>Only show on node pages: ^/node\.php</li><li>Only show on the user page: ^/module\.php\?mod=user</li><li>Show in main page and blog page: ^/(index\.php|module\.php\?mod=blog)</li></ul> - <hr /></p> - <p>The content of the site can be almost entirely altered through <i>boxes</i>. Simply put, boxes are small bits of text, HTML or PHP code which will get plugged into the site just like any other block. Boxes are typically used to add custom blocks to the site.</p> - <p>Each box consists of a title and an associated block of text, HTML or PHP code that can be as long as you wish and that will 'render' the content of the box.</p> - <h3>PHP boxes</h3> - <p>If you know how to script in PHP, PHP boxes are easy to create. Don't worry if you're no PHP-wizard: simply use HTML boxes instead.</p> - <p>You can use any piece of PHP code to make up the content of a PHP box: this implies that you can declare and use functions, consult the SQL database, access configuration settings and much more. A PHP box's code is stored in the database and the engine will dynamically embed the PHP code just-in-time for execution.</p> - <p>There are however some factors to keep in mind when using and creating PHP boxes: PHP boxes can be extremely useful and flexible, yet they can be dangerous and insecure if not properly used. If you are not familiar with PHP, SQL or with the site engine, avoid experimenting with PHP boxes because you can - and probably will - corrupt your database or render your site unusable! If you don't plan to do fancy stuff with boxes then you're probably better off with HTML boxes.</p> - <p>Remember that the code within each PHP box must be valid PHP code -- including things like correctly terminating statements with a semicolon so that the parser won't die. It is highly recommended that you develop your boxes separately using a simple test script on top of a test database before migrating to your production environment.</p> - <p>Note that you can use global variables such as configuration parameters within the scope of a PHP box. Also keep in mind that variables which have been given values in a PHP box will retain these values in the engine or module afterwards.</p> - <p>You can use the <code>return</code> statement to return the actual content for your block as well.</p> - <p><u>A basic example:</u></p> - <p>Given the box with title "Welcome", used to create a "<i>Welcome</i>" box. The content for this box could be created by using:</p> - <pre> - return "Welcome visitor, ... welcome message goes here ..."; - </pre> - <p>If we are however dealing with a registered user, we can customize the message by using:</p> - <pre> - if ($user->uid) { - return "Welcome $user->name, ... welcome message goes here ..."; - } - else { - return "Welcome visitor, ... welcome message goes here ..."; - } - </pre> - <p>For more in-depth examples, we recommend that you check the existing boxes and use them as a starting point.</p> - - <?php + $output .= "<p>Blocks are the boxes visible in the side bars on the left- and/or right-hand side of the web site, depending on the choosen theme. They are either exported by the Drupal engine or by any of the active modules. To really get your teeth into a Drupal web site, you are going to have to deal with blocks and administering blocks in a fairly sophisticated fashion. This means you will need to understand how the block placement strategy works.</p>"; + $output .= "<p>The placement of blocks is delegated to the administrator. In most cases (i.e., the ". l("\"custom\" blocks","admin/block/add") ."), the user has complete control -- using preferences -- over whether or not they are enabled.</p>"; + $output .= "<p>An administrator can lay out and arrange the available blocks to fit in two regions: \"left\" and \"right\". Regions simply contain blocks. In addition, an administrator can assign each block (within a region) a weight to sort them vertically. The heavier blocks will \"sink\" towards the bottom of the column while the lighter blocks will \"float\" towards the top.</p>"; + $output .= "<p>As mentioned, blocks may be arranged to fit in two regions: left and right. For theme builders, each region is identified by a corresponding constant: \"left\" and \"right\". If there is only one region all the blocks are sorted by weight.</p>"; + $output .= "<p>The path setting lets you define which pages you want the specific block to be shown. If you leave the path blank it will show on all pages. The path uses a regular expression syntax so remember to escape special characters!<br />Examples:<ul><li>Only the show block on node pages: ^/node\\.php</li><li>Only show the block on the user page: ^/module\\.php\\?mod=user</li><li>Show the block in main and blog pages: ^/(index\\.php|module\\.php\\?mod=blog)</li></ul><hr /></p>"; + $output .= "<p>The content of the site can be almost entirely altered through ". l("<i>custom blocks</i>", "admin/block/add") .". Simply put, custom blocks are small bits of text, HTML or PHP code which will get plugged into the site just like any other block.</p>"; + $output .= "<p>Each custom block consists of a title, a description, and a body of text, HTML, or PHP code which can be as long as you wish. The Drupal engine will 'render' the content of the custom block.</p>"; + $output .= "<h3>PHP in custom blocks</h3><p>If you know how to script in PHP, PHP custom blocks are easy to create. But don't worry if you're no PHP-wizard: simply use HTML instead.</p>"; + $output .= "<p>You can use any piece of PHP code to make up the content of a PHP custom block: this implies that you can declare and use functions, consult the SQL database, access configuration settings and much more. A PHP custom blocks' code is stored in the database and the engine will dynamically embed the PHP code just-in-time for execution.</p>"; + $output .= "<p>There are however some factors to keep in mind when using and creating PHP custom blocks: PHP custom blocks can be extremely useful and flexible, yet they can be dangerous and insecure if not properly used. If you are not familiar with PHP, SQL or with the site engine, avoid experimenting with PHP custom blocks because you can - and probably will - corrupt your database or render your site unusable! If you don't plan to do fancy stuff with custom blocks then you're probably better off with HTML.</p>"; + $output .= "<p>Remember that the code within each PHP custom block must be valid PHP code -- including things like correctly terminating statements with a semicolon so that the parser won't die. It is highly recommended that you develop your cusom blocks separately using a simple test script on top of a test database before migrating to your production environment.</p>"; + $output .= "<p>Note:<br /><ul><li>You can use global variables, such as configuration parameters, within the scope of a PHP box but remember that variables which have been given values in a PHP box will retain these values in the engine or module afterwards.</li><li>register_globals is now set to <b>off</b>. If you need form information you need to get it from the \"superglobals\" \$_POST, \$_GET, etc.</li></ul></p>"; + $output .= "<p>You can use the <code>return</code> statement to return the actual content for your block as well.</p>"; + $output .= "<p><u>A basic example:</u></p>"; + $output .= "<p>Given the box with title \"Welcome\", used to create a \"<i>Welcome</i>\" box. The content for this box could be created by using:</p>"; + $output .= "<pre> + return t(\"Welcome visitor, ... welcome message goes here ...\"); +</pre>"; + $output .= "<p>If we are however dealing with a registered user, we can customize the message by using:</p>"; + $output .= "<pre> + if (\$user->uid) { + return t(\"Welcome \$user->name, ... welcome message goes here ...\"); + } + else { + return t(\"Welcome visitor, ... welcome message goes here ...\"); + } +</pre>"; + $output .= "<p>For more in-depth examples, we recommend that you check the existing boxes and use them as a starting point.</p>"; + return t($output); + } function block_system($field){ @@ -49,11 +45,13 @@ function block_perm() { function block_link($type) { if ($type == "admin" && user_access("administer blocks")) { - $help["block"] = "Blocks are the boxes visible in the side bars on the left- and right-hand side of the website. They are either exported by the Drupal or by any of the active modules. Adminstrators can enable or disable block, as well control the block placement by assigning them a region and/or by assigning each block (within a region) a weight to sort them vertically. The path setting lets you define which pages you want the specific blocks to be shown."; + $help["block"] = t("Blocks are the boxes visible in the side bars on the left- and right-hand side of the web site, depending on the choosen theme. They are created by <b>active</b> Drupal modules. In order to view a block it must be enabled, then you can assign the block's placement by giving it a region and/or a weight within that region. This sorts them vertically, the smaller the weight, the lighter the block and it will \"float\" towards the top of the page. The path setting is a mask which lets you define on which pages you want the specific block to be shown. The custom checkbox tells Drupal to use a custom designed block, see both <a href=\"%help\">help</a> and <a href=\"%block\">create new block</a> for more information on custom blocks. If you have a custom block then the \"edit\" and \"delete\" operations will be displayed to edit/delete your custom block.", array("%help" => url("admin/block/help"), "%block" => url("admin/block/add"))); + $help["create"] = t("Below create a block to be used in the side bars. Once you have created this block you must make it active, and give it a place on the page by using <a href=\"%overview\">block management</a>. The title is used when displaying the block. The description is used in the \"block\" column on the <a href=\"%overview\">block management</a> page. If you are going to place PHP code in the block, and you have <b>create PHP content</b> permission (see <a href=\"%permission\">user management >> user permissions</a>) you <B>must</b> change the type to PHP to make your code active.", array("%overview" => url("admin/block"), "%permission" => url("admin/user/permission"))); + $help["preview"] = t("This page shows you the placement of your blocks. Each block is represented by its block name, and it's weight. <b>Layout scheme #1</b> is a layout with both left and right columns. <b>Layout scheme #2</b> has only a right column. And <b>layout scheme #3</b> only a left column."); menu("admin/block", "block management", "block_admin", $help["block"], 3); - menu("admin/block/add", "create new block", "block_admin", $help["block"], 2); - menu("admin/block/preview", "preview placement", "block_admin", $help["block"], 3); + menu("admin/block/add", "create new block", "block_admin", $help["create"], 2); + menu("admin/block/preview", "preview placement", "block_admin", $help["preview"], 3); menu("admin/block/help", "help", "block_help", NULL, 9); } } |