Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

repeat region issue

Status
Not open for further replies.

darryncooke

Technical User
May 6, 2009
308
0
0
US
I have a repeat region that is not displaying

before i add the repeat region i have

Code:
<div class="newsBar">
              <h4 class="newsSide"><a href="#" class="purple"><?php echo $row_recordNews['post_title']; ?></a></h4>
              <h5 class="newsSide"><?php echo date('m/d/Y',$row_recordNews['post_date']); ?></h5>
              <?
echo trim_text($row_recordNews['post_content'], 120);
function trim_text($input, $length, $ellipses = true, $strip_html = false) {
	//strip tags, if desired
	if ($strip_html) {
		$input = strip_tags($input);
	}
 
	//no need to trim, already shorter than trim length
	if (strlen($input) <= $length) {
		return $input;
	}
 
	//find last space within length
	$last_space = strrpos(substr($input, 0, $length), ' ');
	$trimmed_text = substr($input, 0, $last_space);
 
	//add ellipses (...)
	if ($ellipses) {
		$trimmed_text .= '...';
	}
 
	return $trimmed_text;
}
?><a href="#" class="purple">Continue</a></div>

when i add the repeat region

Code:
<?php do { ?>
            <div class="newsBar">
              <h4 class="newsSide"><a href="#" class="purple"><?php echo $row_recordNews['post_title']; ?></a></h4>
              <h5 class="newsSide"><?php echo date('m/d/Y',$row_recordNews['post_date']); ?></h5>
              <?
echo trim_text($row_recordNews['post_content'], 120);
function trim_text($input, $length, $ellipses = true, $strip_html = false) {
	//strip tags, if desired
	if ($strip_html) {
		$input = strip_tags($input);
	}
 
	//no need to trim, already shorter than trim length
	if (strlen($input) <= $length) {
		return $input;
	}
 
	//find last space within length
	$last_space = strrpos(substr($input, 0, $length), ' ');
	$trimmed_text = substr($input, 0, $last_space);
 
	//add ellipses (...)
	if ($ellipses) {
		$trimmed_text .= '...';
	}
 
	return $trimmed_text;
}
?>
            <a href="#" class="purple">Continue</a></div>
              <?php } while ($row_recordNews = mysql_fetch_assoc($recordNews)); ?>

the output stops after </h5> for the date. why is the trim function not working in the repeat region?

Darryn Cooke
| The New Orange County Graphic designer and Marketing and Advertising Consultant
| Marketing and Advertising blog
 
nevermind i figured it out.

i cut out the function and put it in the head of my document.

then used echo in my document to call the function.

Darryn Cooke
| The New Orange County Graphic designer and Marketing and Advertising Consultant
| Marketing and Advertising blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top