Prev | Current Page 553 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

tpl");
The default.tpl template contains the following:
{$title}

Author: {$author|default:"Anonymous" }
This returns the following:
Snow Expected in Northeast

Author: Anonymous
Removing Markup Tags
The strip_tags function removes any markup tags from a variable string:
CHAPTER 19 ?–  TEMPLAT ING WITH SMARTY 483
$smarty = new Smarty;
$smarty->assign("title","Snow Expected in Northeast");
$smarty->display("striptags.tpl");
The striptags.tpl template contains the following:
{$title|strip_tags}
This returns the following:
Snow Expected in Northeast
Truncating a String
The truncate function truncates a variable string to a designated number of characters.
Although the default is 80 characters, you can change it by supplying an input
parameter (demonstrated in the following example). You can optionally specify a
string that will be appended to the end of the newly truncated string, such as an
ellipsis (...). In addition, you can specify whether the truncation should occur
immediately at the designated character limit, or whether a word boundary should
be taken into account (TRUE to truncate at the exact limit, FALSE to truncate at the
closest following word boundary):
$summaries = array(
"Snow expected in the Northeast over the weekend.",
"Sunny and warm weather expected in Hawaii.


Pages:
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565