To understand how does BHBsoft.eu works the most simple example is to write in uri:
www.sitenname.com/c_greet__the__world
and display a simple "Hello World!" in a grafic layout.
A framework is not the best choice to display only a Hello World! message,
because we may write
<?php print 'Hello World!'; ?>
in a php file, that's all.
But, if you are able to write an App to print something in some certain conditions
in a certain part of your layout,
to config it good for more conditions,
to setup a form and its filter
and to do connections with the databases and query,
it means that you know to use BHBSoft.eu framework
and you may use the same logic for more complicated apps.
view/greet/index.php
view/greet/img/profile.png dowload from "http://www.bhbsoft.eu/framework/view/cms/img/profile.png"
so you may understand how to create links for css, js and img
and view/greet/img/style.css
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>MyProject</title> <meta name="" content=""> <link href="<?php print \BHB::$rootLayout; ?>img/style.css" rel="stylesheet" type="text/css" media="all" /> </head> <body> <div class="header"> <div class="header_bottom"> <img src="<?php print \BHB::$rootLayout; ?>img/profile.png"> The Header_Top for the Logo and slogan<br /> {<?php print \BHB::layoutAppHere('theHeader_Top', array('greet\model\theapps', 'slogan'), "<b>Default</b>"); ?>} </div> <div class="header_bottom"> The Header_Bottom for the menus.<br /> {<?php print \BHB::layoutAppHere('theHeader_Bottom', array('greet\model\theapps', 'showTime'), "<b>Default</b>"); ?>} </div> </div> <div class="body"> The Body<br /> <?php print \BHB::layoutAppHere("theBody", array('greet\model\theapps', 'sayHello'), \BHB::$uri->get("-1")); ?> </div> <div class="footer"> The Footer<br /> <?php print \BHB::layoutAppHere("theFooter"); ?> </div> </body> </html>
As you can see in the code above, we have defined three places named theHeader_Top, theHeader_Bottom and theFooter
and as default have decide to fill them from the functions/methods showTime() and sayHello() of greet\model\theapps namespace and
giving them the args "<b>Defaults</b>" and \BHB::$uri->get("-1"). You may create an array to send more vars/args into your method.
\BHB::$uri->get("-1") get from URI the first left param of c_ controllerActionMethod or r_ router.
e.g.
www.namesite.com/your_dir_if_there_is_one/thirsdLeft/secondLeft/eng/c_greet__the__world/firstRight/secondRight/bhbVarType=theValue/other_Seo_Or_Vars_For_Your_App/other_For_Seo_Too
print \BHB::$uri->get("-1"); //output eng
print \BHB::$uri->get("-2"); //output secondLeft
print \BHB::$uri->get("bhbVarType="); //output theValue
print \BHB::$uri->get("+1"); //output firstRight
print \BHB::$uri->get("+2"); //output secondRight
view/greet/img/style.css
html { height: 100%; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; color: #717171; } body { height: 100%; text-align: left; background-position: center top!important; background-repeat: no-repeat!important; color: #464646; font-size: 11px; } div.header { float: left; display: block; width: 800px; height: 120px; border: solid 1px green; } div.header_top { float: left; position: relative; display: block; margin-top: 5px; margin-left: 10px; width: 780px; height: 50px; border: solid 1px blue; } div.header_bottom { float: left; position: relative; display: block; margin-top: 5px; margin-left: 10px; width: 780px; height: 50px; border: solid 1px blue; } div.body { float: left; display: block; clear: left; position: relative; width: 800px; height: 400px; margin-top: 3px; border: solid 1px green; } div.footer { float: left; display: block; clear: left; position: relative; width: 800px; height: 100px; margin-top: 3px; border: solid 1px green; }
.
<?php //For every place in layout grafic that may be populated with diferente content //give a (name) as key and an (array 0=>position, 1=>nameOfMethod, 2=>SomeVarsToHelpYou) as Value. return array( "theHeader_Top" => array('greet\model\theapps', 'sloganDefinedByConfigurator', '<b>Defined In Configurator</b>'), //"" => "", //add for the other places in layout. ); ?>
Well, now we have our grafic file and it looks very clean.
Lets start now to create the Controller and the Model.
Inside the model, after our business logic and actions, we will define the layout grafic to use writing:
\BHB::useLayout("greettheworld", "index.php");
If we want to show the default Apps in every place don't define anything in Model or layoutAppConfigurator.
If we have written a layoutAppConfigurator, it will be considered, as second because as first is what we defined in Model.
If we want to change some apps we just define it here, in Model or App.
<?php namespace greet\controller\the; class the { public function world() { //we load a business logic that we shall write in Model. \BHB::$load->f('greet\model\the')->world(); // \BHB::$load->f() //for loading the model // ->world(); //is for calling the method world(); } } ?>
<?php namespace greet\model\the; class the { public function world() { //Usually here you may do some business logic. //Dcide which layout you are going to use for this output. \BHB::useLayout('greettheworld', 'index.php'); //print \BHB::$fileLayout; //now we lets test the three ways to fill with content our layout. //\BHB::layoutAppThis('theHeader_Top', array('greet\model\theapps', 'sloganDefinedByModel'), "<b>Defined In Moedl</b>"); //to not fill with an App. just put ...array(), first or second arg == ''. \BHB::layoutAppThis('theHeader_Top', array('', 'sloganDefinedByModel'), "<b>Defined In Moedl</b>"); //\BHB::layoutAppThis('theHeader_Bottom', array('greet\model\theapps', 'showTime'), "<b>Defined In Moedl Too</b>"); \BHB::layoutAppThis('theFooter', array('greet\model\theapps', 'forTheFooter')); require_once(\BHB::$fileLayout); } } ?>
<?php namespace greet\model\theapps; class theapps { //************************************************ public function slogan($args) { //print "The time is ".date("H:i:s"); ?> A new php5 oop GPL Framework <?php print $args; ?>! <?php } //************************************************ public function sloganDefinedByConfigurator($args) { ?> A new php5 oop GPL Framework <b><?php print $args; ?></b>! <?php } //************************************************ public function sloganDefinedByModel($args) { ?> A new php5 oop GPL Framework <?php print $args; ?>! <?php } //************************************************ public function showTime($args) { return "The time is: ".date("H:i:s")." ".$args; } //************************************************ public function sayHello($theLang) { ?> <div style="float:left;margin-left:200px;margin-top:100px;width:300px;height:120px;border:solid 3px #ccc;text-align:center;"> <?php print $theLang; ?><br /> <h2>HELLO WORLD!</h2> <br />from "BHBSoft.eu" Framework </div> <?php //$toReturn = "<h2>HELLO WORLD!</h2>"; //return $toReturn; } //************************************************* public function forTheFooter() { ?> BHBSoft.eu is a GPL Project! <? } }
namespace greet\model\theapps;to
namespace greet\model\subdirapp\theapps;and change the file model/the.php from
\BHB::layoutAppThis('theFooter', array('greet\model\theapps', 'forTheFooter'));to
\BHB::layoutAppThis('theFooter', array('greet\model\subdirapp\theapps', 'forTheFooter'));