Skip to content

Commit

Permalink
Fix loremipsum partial and add new parameter
Browse files Browse the repository at this point in the history
New parameter is withoutTags and it's
set by default.
  • Loading branch information
hkirsman committed Dec 13, 2011
1 parent 28cfb80 commit dab0885
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 23 deletions.
41 changes: 41 additions & 0 deletions _html-warrior/templates/partials/loremipsum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

require_once($config["code_path"].'/externals/LoremIpsum.class.php');


$out = '';


if (!isset($params['withoutTags'])) {
$params['withoutTags'] = true;
}


if (!$params['wordCount']) {
$wordCount = 100;
} else {
$wordCount = $params['wordCount'];
}


if (!$params['paragraphCount']) {
$paragraphCount = 1;
} else {
$paragraphCount = $params['paragraphCount'];
}


for($i=0;$i<$paragraphCount;$i++) {
if ( !isset($loremIpsumGenerator) ) {
$loremIpsumGenerator = new LoremIpsumGenerator;
}
$out .= $loremIpsumGenerator->getContent($wordCount)."\n";
}


if ($params['withoutTags']) {
$out = strip_tags($out);
}


$params['out'] = $out;
24 changes: 1 addition & 23 deletions _html-warrior/templates/partials/loremipsum.tpl
Original file line number Diff line number Diff line change
@@ -1,23 +1 @@
{php}
global $config, $wordCount, $smarty;
require_once($config["code_path"].'/externals/LoremIpsum.class.php');

if (!$smarty->tpl_vars['wordCount']->value) {
$wordCount = 100;
} else {
$wordCount = $smarty->tpl_vars['wordCount']->value;
}

if (!$smarty->tpl_vars['paragraphCount']->value) {
$paragraphCount = 1;
} else {
$paragraphCount = $smarty->tpl_vars['paragraphCount']->value;
}

for($i=0;$i<$paragraphCount;$i++) {
if ( !isset($loremIpsumGenerator) ) {
$loremIpsumGenerator = new LoremIpsumGenerator;
}
echo $loremIpsumGenerator->getContent($wordCount)."\n";
}
{/php}
{$out}

0 comments on commit dab0885

Please sign in to comment.