You can use PHP to customize your Developer Portal blocks. Using PHP
to customize your blocks is an advanced option, and widens the customization capability of the Developer Portal.
Before you begin
You must have administrator access to complete this task.
You must also have prior PHP experience.
About this task
CAUTION:
Allowing the use of PHP can affect the security of your Developer Portal site.
Procedure
-
Allow embedded PHP code to be evaluated in the Developer Portal:
-
Click Modules in the administrator dashboard.
-
Switch the PHP filter to ON.
-
Click Save configuration.
-
Configure the Developer Portal to use PHP
code:
-
Click Configuration in the administrator dashboard.
-
Under the CONTENT AUTHORING heading, click Text
formats.
-
Click configure under the OPERATIONS heading for
the PHP code row.
-
Under the Roles heading, select the administrator check box. If you enable PHP code for a role,
anyone in that role can execute PHP code. Do not enable this option for roles in which PHP code is
not used to edit and configure blocks.
-
Click Save configuration.
-
Remove the WYSIWYG editor capabilities for PHP code:
Note: The WYSIWIG editor is not compatible with PHP code, and must be switched off for PHP
code.
-
Select Configuration in the administrator dashboard.
-
Under the CONTENT AUTHORING heading, click Wysiwyg
profiles.
-
Click Edit for PHP code.
-
Expand the BASIC SETUP section.
-
Deselect the Enabled by default check box.
-
Click Save.
-
Create a custom block for your PHP code:
-
Select Structure in the administrator dashboard.
-
Click Blocks.
-
Click Add block.
-
Assign a name and description to your new custom block.
-
Under the Block body heading, use the Text format
drop-down list to select PHP code.
- Optional:
You can enter the PHP code manually by clicking Disable rich-text under
the Block body heading. PHP tags should be used, as in the following example:
<?php print "myCustomBlockCode"; ?>
-
Click Save block.