Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Requires: phpFox version >= 4.3

...

...

Modifying an HTML Block/Controller

In order to modify an existing HTML block or controller, you need to create these files within your your html/ folder in your theme.

For this example, we are going to modify the "Friends Online" block that shows up in a user's dashboard when they are logged in. This meansTo do this, we try to need overwrite the HTML block file file PF.Base/module/friend/template/default/block/mini.html.php.   There are two ways for you to do this:

  1. Clone the file PF.Base/module/friend/template/default/block/mini.html.php into into your themes themes html/ folder folder. Rename the clone file to to friend.block.mini.html.php. Modifying this file will help you overwrite the original block file. Just like the original file, you can use the module template engine (phpFox engine template used in core modules, similar to Smarty) in this file. This way is very useful and easy in case you only want to make some mini changes on the template.   (Requires: 4.4.0+)
  2. If you want to re-write the template completely, or want to use the the Twig engine template(new template engine phpFox using for apps),  create create a file called called friend.block.mini.html in in your theme's html/ folder folder.
  3. For this example, we will use static code to check. Add the code below to the file you have just created. Please note that if you have both of the files (friend.block.mini.html.

...

  1. php and friend.block.mini.html), the core will prefer to use the

...

  1. file friend.block.mini.

...

  1. html to overwrite.
Code Block
languagehtml
themeRDark
borderStylesolid
linenumberstrue
collapsefalse

<div class="block">
   <div class="title">
      Friends Online
   </div>
   <div class="content">
      ...
   </div>
</div>

To make sure the changes take place, clear your site's cache from the AdminCP.

...

In addition to modifying blocks, you can also create a new block. Similar to apps, themes can bootstrap a PHP file called called start.php. From this file you can add blocks and use any of the API Functions provided to apps.

In your theme create a file called called start.php php and paste the following following

Code Block
languagephp
themeRDark
borderStylesolid
linenumberstrue
collapsefalse

block(1, 'core.index-member', function() {
   $html = '<div class="block"><div class="title">Hello World</div><div class="content">...</div></div>';

   return $html;
});

Learn more about the the block()  function here.