Get Smarty

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Check reviews of PHP Web Hosting, compatible with Smarty Templates

Name

register_block (Block-Funktion registrieren)

void register_block(string name,
                    mixed impl,
                    bool cacheable,
                    mixed cache_attrs);

Wird verwendet, um Block-Funktion-Plugins dynamisch zu registrieren. Übergeben Sie dazu den Namen der Block-Funktion und den Namen der PHP-Callback-Funktion, die die entsprechende Funktionalität bereitstellt.

Der Parameter impl kann als (a) einen Funktionnamen oder (b) einem Array der Form array(&$object, $method), wobei &$object eine Referenz zu einem Objekt und $method der Name der Methode die aufgerufen werden soll ist, oder als Array der Form array(&$class, $method), wobei $class der Name der Klasse und $method der Name der Methode ist die aufgerufen werden soll, übergeben werden.

$cacheable und $cache_attrs können in den meisten Fällen weggelassen werden. Konsultieren Sie Die Ausgabe von cachebaren Plugins Kontrollieren für weitere Informationen.

Example 13.21. register_block (Block-Funktion registrieren)


<?php
$smarty->register_block("translate", "do_translation");

function do_translation ($params, $content, &$smarty, &$repeat)
{
  if (isset($content)) {
    $lang = $params['lang'];
	// &uuml;bersetze den Inhalt von '$content'
    return $translation;
  }
}
?>

   

Wobei das Template wie folgt aussieht:


{* template *}
{translate lang="br"}
Hello, world!
{/translate}

   

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 12 plus 20? (Are you human?)

Sponsors [info]

Cheap Website Hosting @hostdone.com
Cheap Hosting @HostsVault
email marketing @ActiveCampaign
broadband deals @BroadbandGenie
Best UK Web Hosting @webhost.uk.net
Reliable UK and US Web Hosting @rshosting.com
Cheap US and UK Web Hosting @infrenion.com
I.T Certification Exams @pass-guaranteed.com
Certification Practice Tests @firsttrycertify.com
Certification Practice Exam Questions @ace-it-certifications.com
Broadband Speed Test @broadbandspeed.co.uk
bulk email software @americaint.com