Forum
Difference in the way :content and :blog are handled?
I have added a php function to strip <p>
tags from around <img>
tags.
function stripP($html){
return preg_replace('%(.*?)<p>\s*(<img[^<]+?)\s*</p>(.*)%is', '$1$2$3', $html);
}
I am using it with perch:content
like this
$result = perch_content_custom('Projects', array(
'page' => '/index.php',
'template' => 'project-detail.html',
'filter' => 'project-slug',
'match' => 'eq',
'value' => perch_get('p'),
'count' => 1,
'skip-template' => true,
'return-html' => true,
));
echo stripP($result['html']);
// I am doing it this way because I need additional information for pagination
// This works as intended
Then in the blog
$result = perch_blog_custom(array(
'template' => 'post.html',
'filter' => 'postSlug',
'match' => 'eq',
'value' => perch_get('post'),
'paginate' => false,
'count' => 1,
'skip-template' => true,
'return-html' => true,
));
echo stripP($result['html']);
// This does not strip the p tags
Any thoughts?
Hmm don't know why that second code block isn't working...
What does
$result
look like?$result is an array with all the region info in it plus the
['html']
key which is the long string of html that the perch call would normally return I would think...Ok, so if the return value from Perch is correct, then is it not more likely that the problem is somewhere in your code?
Yes, I am just making sure because it works fine in one place and not in another. I've tried several irritations all with the same outcome, works in perch:content, but not perch:blog. I'll dig in again and see I catch anything else going on.