Menu Blocks and Items
From PhpCOIN Documentation
Contents |
Sidebox Menus
phpCOIN can display one or more menu blocks in either or both of the left and right-hand columns. Each menu block can contain hyperlinks or images or even the output from a php function. As an example, in the left-hand column of this site are two Menu Blocks (navigation and toolbox) and within each block are several Menu Items.
Menu Blocks
A Menu Block is the "wrapper" that holds one or more Menu Items. In Admin -> Menu Blocks you can select an existing Menu Block to edit or delete, or you can add a new Menu Block. When adding or editing, each Menu Block looks like this:
- Position: The display order of the block
- Title: The header for the block
- Status: ON is viewable, OFF is not displayed
- Admin Block: YES means that only a logged-in admin can see the block
- User Block: YES means that only a logged in user or admin can see the block
- Column: Whether this block should appear in the left-column or the right-column or neither column on pages that have the appropriate column turned ON in Admin -> Components
Menu Items
A Menu Item is part of the actual content for a Menu Block. A Menu Block will hold one or more Menu Items, which means that you can add as many individual hyperlinks or images or functions output to a menu block as you like. You can also mix and match the Menu Items, so a Menu Block can have hyperlinks and/or images and/or function outputs.
In Admin -> Menu Blocks you can select an existing Menu Item to edit or delete, or you can add a new Menu Item to an existing Menu Block. When adding or editing, each Menu Item looks like this:
- Block ID: Which Menu Block this item is assigned to.
- Item ID: The order to display the item in within the block
- Text: The content for the item ~ what the user sees
- URL: Where to link to, if it is a linkable item
- Target: Whether the link should open in a new window, the same window, etc.
- Type: Whether this is a text hyperlink, an image, or the output from a php function
- Status: ON means the item is visible, OFF is not displayed
- Admin Item: YES means that only a logged-in admin can see the item
- User Item: YES means that only a logged in user or admin can see the item
Menu Item Types
A Menu Item can be text or an image or the output from a php function. A Menu Block will hold one or more Menu Items, which means that you can add as many individual hyperlinks or images or functions output to a menu block as you like. You can also mix and match the Menu Items, so a Menu Block can have hyperlinks and/or images and/or function outputs:
Text Hyperlink
For the Menu Item:
- Enter the text for the link in the "Text" field.
- Enter the hyperlink URL in the "URL" field.
- Set the "Type" to "Text"
Text: phpCOIN.com URL: http://www.phpcoin.com Type: Text
Text: Place Order URL: mod.php?mod=orders Type: Text
Image
First define the image in the /coin_themes/theme/config.php file. The quickest way is to copy one of the existing image definitions, and edit the $_TCFG name and the actual image filename as required.
If you use $_PARM_PREFIX in the definition, then phpCOIN will expect to find the image in the coin_themes/theme/images/nav directory.
$_TCFG['_IMG_NEW_BUTTON'] = $_PARM_PREFIX.'new_button.gif' .'" alt="'.$_LANG['_THEME']['ALT_IMG_NEW_BUTTON'] .$_PARM_SUFFIX; // Image URL for: "New Button" Button (big)
Or you may choose to place the image in the /coin_images directory:
$_TCFG['_IMG_NEW_BUTTON2'] = '<img src="coin_images/new_button2.gif" border="0">';
For the Menu Item:
- Enter the variable name for the image in the "Text" field. The variable name must begin with "$" and no single quotes in the variable.
- Enter the URL that the image will redirect to when clicked in the "URL" field.
- Set the "Type" to "Image".
Text: $_TCFG[_IMG_NEW_BUTTON] URL: http://www.mysite.com/myurl.php?myid=5 Type: Image
php Function
First add the function to the /coin_includes/custom.php file. Even better is to add your function to /coin_overrides/custom_override.php so that future upgrades to phpCOIN will not overwrite your custom function(s). Some restrictions on the function:
- The function must return the output and not echo it. If you echo it, you will end up with the output at the wrong place on the screen.
- The function name MUST begin with "do_" for security reasons.
- Remember where the output is going. Use something too wide, or that outputs pages of info, and the menu block will reflect this.
Here is an example of a php function that will output an image and text:
<?php
function do_show_paypal_graphics() {
$_images = '<div align="center">';
$_images .= 'We accept<br>';
$_images .= '<img src="coin_images/paypal_methods.gif" border="0" alt="PayPal">';
$_images .= '</div>';
return $_images;
}
?>
For the Menu Item:
- Enter the name of the function, minus the "do" prefix, in the "Text" field. This input must begin with the leading underscore "_" and must match the function name except for the leading "do".
- Enter n/a for the "URL" because it is ignored.
- Set the "Type" to "Function".
For example, if your custom function in located in /coin_overrides/custom_override.php and it is called do_show_paypal_graphics()
Text: _show_paypal_graphics URL: n/a Type: Function



