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

Helping function used for blocks



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

      maketitle($var1 = "", $var2 = "", $var3 = "")

This function is used to assign the page title tag '' where '$var1', '$var2' and '$var3' are title variables noting that titles are filtered and protected against the XSS.

Example:

CODE :
maketitle($dimphrase['printing_content']);

      maketree($rootcatid, $module)

This function is used to build a tree branching code for section (Breadcrumb), to clarify the classification of content or section where you are now and where it comes from.

Parameters:

  • $rootcatid (mandatory): the ID number of the section which includes the content or section.  
  • $module (mandatory): the name of the table within the database which includes the module that contains the section.

Example:

CODE :
maketree($dimofinf->GPC['id'], "articles")

Please note:

The block file must include the following blocks and variables so that the function would replace them with the values they return which are in the form of the HTML code of the branching.

Example (you can use it replacing what you need to, to fit your module):

CODE :
<[START BLOCK : subcat]>
	{output} <a href="{function:getpermalink file="cards" args="action=l&id={catid}" caption="{catname}"}"> {catname}</a></td></tr><tr><td align="{lang_left}" height="16">
<[END BLOCK : subcat]>
	
<[START BLOCK : currcat]>
	{output} <a href="{function:getpermalink file="cards" args="action=l&id={catid}" caption="{catname}"}"> {catname}</a></td></tr><tr><td align="{lang_left}" height="16">
	{outputcaption}   {caption}
<[END BLOCK : currcat]>

      catprev_next($page, $perpage, $results, $address1, $address2 = '')

This function is used to create multiple pages within the block for the sections.

Parameters:

  • $page (mandatory): the number of the displayed page and this comes from the variable 'catpage' which is sent with the page.
  • $perpage (mandatory): the number of sections to display per page.
  • $results (mandatory): the total number of sections.
  • $address1 (mandatory): the main action title for the page.
  • $address2 (optional): the additional variables in the page title.

Example:

CODE :
$pages = catprev_next($dimofinf->GPC['catpage'], $perpage, $count['total'], "l", "&id=" . $dimofinf->GPC['id'] . iif($dimofinf->GPC['page'] > 1, "&page=" . $dimofinf->GPC['page']));
$tpl->assignGlobal("catprev_next",$pages);

Please note:

The block file must contain the following variable so that the function can replace it with the value it returns which is the HTML code responsible for multiple pages for the sections.

{catprev_next}

      prev_next($page, $perpage, $results, $address1, $address2 = '')

This function is used to create multiple pages within the block for contents.

Parameters:

  • $page (mandatory): the number of the current displayed page and this comes from the variable 'page' which is sent with the page.
  • $perpage (mandatory): the number of contents to display per page.
  • $results (mandatory): the total number of contents.
  • $address1 (mandatory): the main action title for the page.
  • $address2 (optional): the additional variables in the page title.

Example:

CODE :
$pages = prev_next($dimofinf->GPC['page'], $perpage, $count['total'], "l", "&id=" . $dimofinf->GPC['id'] . if($dimofinf->GPC['catpage'] > 1, "&catpage=" . $dimofinf->GPC['catpage']));

Please note:

The block file must contain the following variable so that the function can replace it with the value it returns which is the HTML code responsible for multiple pages for the contents.

{prev_next}

      Internal blocks functions:

As it has been clarified before in the internal functions tag, you can write your own function to use it within the block by following these simple steps:

  • Create a file within the 'include/functions' folder using this name form 'functions.name.php' where 'name' is the function name.
  • Write the following function formula in the function file:
CODE :
function Dimofinf_function_name($params)
    {
    	return $val;
    }

Where 'name' is the function name and '$params' is a matrix that includes the function parameters which are called when the function is called from within the block as every entry takes an index in the '$params' matrix and its value is the inserted value noting that the function should return a value at the end where '$val' is an example for the reference value from the function.

An example of the 'getpermalink' function which is called from within the block and thus it does the processing from the main function in the (PHP):

CODE :
function Dimofinf_function_getpermalink($params)
    {
    	if(isset($params['file'])){
    		return getpermalink($params['file'],$params['args'],$params['outputfiletype'],$params['default'],$params['caption']);	
    	}
   }

            An example for calling it in the block:

{function:getpermalink file="albums"}


Was this answer helpful?

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

Also Read

Blocks system (Views: 477)

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


$tpl object functions within the PHP file (Views: 391)

    - mk_template($var) This function is called to create a $tpl object as special $tpl...


Modifiers functions (Views: 507)

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


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

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


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