Optimizing Concrete5 for Search Engines ?

Permalink
Hi,

I'm trying to play around with meta description. So that users do not have to write their own description, but letting Concrete5 use the text from the "Content" blog. So that non tech savvy people don't have to add the pageDescription themselves.

I got the pageDescription stripped and what not, but I still don't know, how I can tell it to use the content that is inside the "Content" area ?

<meta name="description" content="<?php
$limit=255; // Define how many character you want to display.
$metaDescription = htmlspecialchars ($pageDescription, ENT_COMPAT, APP_CHARSET);
$metaDescription = trim( preg_replace( '/\s+/', ' ', $metaDescription ) );
$showMetaDescription = substr($metaDescription, 0, $limit); 
echo $showMetaDescription
?>" />

 
TheRealSean replied on at Permalink Reply
TheRealSean
I don't know if this will work? but in theory

$textHelper = Loader::helper("text");
if($c->getAttribute('meta_description')==""){
 $blocks = $c->getBlocks('Main');
 foreach($blocks as $b) {   
  if($b->getBlockTypeHandle()=='content'){
   //I dont know if this bit will work as I dont know the exact call
   //to get to the controller from the $b object?
   $content = $b->controller->getContent();
   $description = strip_tags($textHelper->shorten($content,200));
   $c->setAttribute('meta_description', trim($description));
   }
  }
}
TheRealSean replied on at Permalink Reply
TheRealSean
The idea being to grab the blocks within main grab the content block(the code will use the last instance it finds) then grab the content from that block reduce it to 200 chars and add it to the meta description.

I only have one content block in my main(and I use the $_POST value as I am dealing with an entry from the dasboard)