Knowledgebase



 Categories





 Dimofinf Mobile


Subscribe now to Dimofinf Mobile and enjoy a wide range of premium services. You will receive our SMS text messages wherever you are for a very low cost! More


 Currency Converter


  • Currency
  • US$ Amount

$tpl object functions within the PHP file



    - mk_template($var)

This function is called to create a $tpl object as special $tpl objects aren't defined by the block system and its functions can't be executed prior to calling this function where the '$var' variable is the name of the block file you wish to prepare noting that it is added in full including the extension.

Please note:

When preparing a block from the main style blocks folder, just add the block name directly but when you want to call a block file from another path other than the block folder of the main style, add the block path. For example, when preparing a block from one of the folders in a plugin:

CODE :
mk_template("article/tpl/article.htm");

Where 'article' is the name of the plugin folder and 'tpl' is the blocks folder for the plugin and 'article.htm' is the block.

    - newBlock($var)

This function is used to define the loop block within the block where '$var' is the block name noting that to repeat the display of the block within the block more than once, this function is called with the same block name more than once.

Example:

1- A single block:

- The block form within the block:

CODE :
[START BLOCK : blockname]> <[END BLOCK : blockname]

- Defining the block within the PHP file:

CODE :
$tpl->newBlock("blockname");

2- A multiple block:

- The block form within the block:

CODE :
[START BLOCK : blockname]>        <[START BLOCK : blockname2]>         <[END BLOCK : blockname2]><[END BLOCK : blockname]

- Defining the block within the PHP file:

CODE :
// Defining the main block in the beginning
$tpl->newBlock("blockname");				
//Defning the sub-block but the single parent block must be added to the sub-block
$tpl->newBlock("blockname,blockname2");

Please note:

More than one block should be placed within the block in s tree form, and when defined, the tree path of the block is entered starting from the parent block to the sub-block separating them by a comma.

    - assign($var,$value='')

This function is used to assign the values of the variables defined within the defined block only as it is used after a block is defined using the function 'newBlock()' where '$var' is the name if the variable within the defined block in the block and '$value' is the variable value noting that you can pass a matrix of variables and their values in one batch to the function instead of repeating the function calling more than once for every variable where the key is the variable name and the value is the variable value.

Example:

CODE :
$tpl->assign("m", THIS_SCRIPT);
$tpl->assign(array(
	"totalcatkeys" => $num_rows,
	"catkey" => $catkeys,
	"width" => $catwidth,
	"cat_id" => $cat['id'],
	"cat_name" => $cat['name'],
	"description" => bbcodeparse($cat['description'], THIS_PRODUCT, true),
	"last_add" => $last_add
));

    - assignGlobal($var,$value='')

This function is used to assign values for defined global variables within the block and aren't related to a block. This function can be used without needing to define a block whether in the block or in the PHP file, where '$var' is the name if the variable within the defined block in the block and '$value' is the variable value noting that you can pass a matrix of variables and their values in one batch to the function instead of repeating the function calling more than once for every variable where the key is the variable name and the value is the variable value.

Example:

CODE :
$tpl->assignGlobal("thelast", 1);

Please note:

Global variables values can be assigned in another way if the '$tpl' object isn't defined using the global variable '$Globalassigneds' which includes a matrix of variables and their values.

CODE :
$Globalassigneds = array_merge($Globalassigneds, array(
	"allow_add" => $allow_add,
	"forum_id" => $dimofinf->GPC['id']
));

    - gotoBlock($var)

This function is used for shifting between defined blocks in the PHP file, the advantage of the shifting is that if you have defined the block 'blockname1' then you assigned values for defined variables within the block using the 'assign' function after which you wanted to define another block by the name 'blockname2' and you assigned values for defined variables within the block using the 'assign' function then you wanted to go back to the 'blockname1' block to assign new values for the variables, this function advantage rises where '$var' is the name of the block you want to shift to, provided that it is predefined.

Example:

CODE :
$tpl->newBlock("catinfo");
$tpl->assign(array(
						"totalcatkeys" => $num_rows,
						"catkey" => $catkeys,
						"width" => $catwidth,
						"cat_id" => $cat['id'],
						"cat_name" => $cat['name'],
						"description" => bbcodeparse($cat['description'], THIS_PRODUCT, true),
						"last_add" => $last_add
					));
$tpl->newBlock("catinfo","catinfopic");
$tpl->assign(array(
							"cat_id" => $cat['id'],
							"catpicture" => $cat['picture'],
							"cat_name" => $cat['name']
));
$tpl->gotoBlock("catinfo");
$tpl->assign("fgf", "fgf");

    - printToScreen()

This function is used in printing the block to the browser directly in the end after processing.

Example:

CODE :
$tpl->printToScreen();

    - getOutputContent()

This function is used to return the block in the form of 'String' to the browser after processing without printing it.

Example:

CODE :
$tpl->getOutputContent();

    - variable($variable,$currentBlock = false)

This function is used to return the value of a defined variable within the block or a global variable but from the PHP code whether from block file using the PHP code tag or through the PHP file where the '$variable' is the name of the defined variable within the block and '$currentBlock' is the name of the block which includes the variable (is the variable isn't a global and defined variable within the block) noting that you can pass a tree block branched from a main block by providing the block branching in full separated by a comma.

Example:

CODE :
$tpl->variable('variable');
$tpl->variable('variable','blockname');
$tpl->variable('variable','blockname1,blockname2');

Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read

Helping functions which can be used in the blocks (Views: 535)

      {function:alternate name="blockname" values="alt1,alt2"} This function is used to...


Blocks system (Views: 477)

Dimofinf offers you an exclusive state of the art blocks system through which you can separate...


Modifiers functions (Views: 508)

As it has been explained before in the variables tag, modifiers are functions that modify the...


Helping function used for blocks (Views: 479)

This is a set of helping functions which can be used in your programming for some ready parts...


Block system tags within the block files & Variables, constants and general variables (Views: 560)

Block system tags within the block files: The blocks system has several tags that are placed in...



Online