Thursday, September 3, 2009

Customizing your Dolphin Community - a popular topic

Now let's look at PHP within Dolphin and pull it together. I hope this post will help you customize your dolphin (community) site. We'll start by dissecting a simple page from the Dolphin community builder application.

You should read the previous post ( a simple PHP primer ) before reading this popular blog entry on customizing your dolphin web site. It will help you see the very basic PHP skill you should have before customizing your web site yourself.

Let's go ahead and open the file (dolphin root directory) /faq.php - this is the simplest file to start with, when customizing your Boonex community software.

After the Boonex copyright, you will notice the next 2 lines.

require_once( './inc/' );
require_once( BX_DIRECTORY_PATH_INC . '' );
These lines include important files for the dolphin framework and should not be removed.

Next in the dolphin page framework we tell it:
$_page['name_index'] = 13;
$_page['css_name'] = 'faq.css';
$_page['name_index'] Tells dolphin to use that numbered template (from the tmpl_uni directory) These template files are called page_xxx.html in your template directory (templates/tmpl_xxx/)

$_page['css_name'] Tells dolphin to include that named css file (for style) 
NOTE: For it to pickup and use the CSS file you reference in this setting, the css file must be in the /templates/tmpl_uni/css/ directory.

Then you will notice more PHP....

if ( !( $logged['admin'] = member_auth( 1, false ) ) )
if ( !( $logged['member'] = member_auth( 0, false ) ) )
if ( !( $logged['aff'] = member_auth( 2, false ) ) )
$logged['moderator'] = member_auth( 3, false );
This is where dolphin looks for the security details.. what level is the current user logged in as. Again, do not alter this yet - we can cover the user-level access in another post about Dolphin security.

Here Dolphin will set some page content but get the actual content from your specific dolphin install and admin settings.

$_page['header'] = _t( "_FAQ_H" );
$_page['header_text'] = _t( "_FAQ_H1", $site['title'] );
Take notice of the function this calls:

$_page['header'] = (we want that variable to be set at runtime)

_t( "_FAQ_H" ); This is what we want to set it to: This is actually the language function, it uses the function _t to get the value from the language settings (managed in dolphin admin panel)

For this example - the function _t uses the language entry _FAQ_H -- which means: in the language file there is an item (key) called _FAQ_H with a value that will replace the _FAQ_H at run time.
You will also notice the use of another variable (being passed to the _t function (  $site['title'] ) this is set in the file in your /inc/ directory and references the site title, you chose during install (or later edited when customizing your dolphin site.
Now the server has processed the above and is creating the HTML content to send to your visitors web browser. It still does not have the bulk of the page - the actual content.

Content is created by the PageCompPageMainCode() function.

$_page_cont[$_ni]['page_main_code'] = PageCompPageMainCode();

$_page_cont[$_ni]['page_main_code']  is what we want to replace with the results of the PageCompPageMainCode() function. Which, if you look at the template file you will see it as 
__page_main_code__ -> and notice where it will place those results in a basic HTML structure.

Lets dissect that function for better understanding how to make changes to it and customize your dolphin community to get out of the cookie cutter contents of such an open source application.

function PageCompPageMainCode()
global $oTemplConfig;
    $ret = _t( "_FAQ_INFO" );
    return DesignBoxContent(_t( "_FAQ_H1", $site['title'] ), $ret, $oTemplConfig -> PageCompThird_db_num );

 $ret = _t( "_FAQ_INFO" ); -- This is setting the $ret (the HTML code we want in the main content of the page) - it gets the _FAQ_INFO value from that key's entry in the language file. and puts it in the variable $ret

Then... we want to put that value into a Design Block on that page....

return DesignBoxContent(_t( "_FAQ_H1", $site['title'] ), $ret, $oTemplConfig -> PageCompThird_db_num );

Here the PHP 'returns' the design box with the header _FAQ_H1, the site title and then (3rd variable) the actual content from the language key. The final setting there PageCompThird_db_num chooses the type of design box -- border, no border etc.

We can cover those in more details in another post - hopefully this will introduce the very basics of manipulating dolphin into a truly customized social community.

Much more to learn as we move forward creating your unique dolphin site.

See you next time.

No comments:

Post a Comment