Jump to content

Recommended Posts

Posted

Ryan can you help with this body copy

in my template i am using like this,

<?php
		$children = $pages->get("/futboll/")->children("sort=-created, limit=3");
		foreach($children as $futboll) {
		$image = $futboll->images->first();
		$thumb = $image->size(100, 100);		  
		echo "
		<ul class='latestnews'>
		<li><img src='{$thumb->url}' alt='Sport Kosova' />
		<p><strong><a href='{$futboll->url}'>{$futboll->title}</a></strong></p><p class='bardh'></br>{$futboll->summary}</p>
		</li>
		</ul>
		";
		}
		?>

and i like to limit body text in blog i try some your recommendation like:

if($skyscraper->body) {
		$summary = strip_tags($skyscraper->body); 
		if(strlen($summary) > 500) { 
			$summary = substr($summary, 0, 500); // display no more than 500 chars
			$summary = substr($summary, 0, strrpos($summary, ". ")+1); // and truncate to last sentence
		} 
		$summary = trim($summary); 
	} else $summary = '';

	$out = 	"\n\t<tr class='skyscraper_details'>" . 
		"\n\t\t<td rowspan='2' class='skyscraper_image'><a href='{$skyscraper->url}'>$img</a></td>" . 
		"\n\t\t<td><a href='{$skyscraper->url}'>{$skyscraper->title}</a></td>"; 

But i am gating blank in body or summary fields,

Posted

The code you posted in the second snippet is from the skyscrapers site, so if you copied that directly you would need change the variable names and such to match your own. If you are already doing that, can you post the actual code snippet you are using?

Posted

Hey thanks Ryan i read step by step and now i fix it its work perfect ,

i use like this code,

              <?php
		$children = $pages->get("/f1/")->children("sort=-created, limit=3");
		foreach($children as $f1) {
		$image = $f1->images->first();
		$thumb = $image->size(185, 130);
		$summary = substr($f1->body, 0, 120);
		echo "
		<li><a href='{$f1->url}'><img src='{$thumb->url}' alt='Sport Kosova' /></a>
		<p class='bardh'>$summary</p>
		<p class='readmore'><a href='{$f1->url}'>Vazhdo Leximin »</a></p>
		</li>
		";
		}
Posted

Heres the code I used to truncate and to make sure it ends in a word (so association wont become ass...), maybe it could be of some use as well as Ryan's example  :):

<?php
if (strlen($vDescription) > 16) {
                $shortDescription = substr($vDescription, 0, 16); // truncate string
                $shortDescription = substr($shortDescription, 0, strrpos($shortDescription, ' '))."…<br /><a href='{$vehicle->url}'> Read more</a>"; // make sure it ends in a word 
              } else {$shortDescription = $vDescription;}
  • Like 1
Posted

Thanks Arkster ,

for now i am using like this i am Truncate-d and title too and its working perfect in template, example gjelbert.co

<?php
	foreach($page->children("sort=-created, limit=4") as $child) {
		$image = $child->images->first();
		$thumb = $image->size(100, 70);
		$summary = substr($child->body, 0, 80);
		$titulli = substr($child->title, 0, 19);
          echo "
	  <ul class='latestnews'>
	  <li>
	  <a href='{$child->url}'><img src='{$thumb->url}' width='{$thumb->width}' height='{$thumb->height}' alt='Sport Kosova' /></a>
          <p><a href='{$child->url}'>$titulli</a></p>
	  <br>$summary</br>
	  </li>
	  </ul>
          ";
          }

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...