Forum

Thread tagged as: Question, Problem, Blog

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?

Nicholas Nelson

Nicholas Nelson 0 points

  • 7 years ago

Hmm don't know why that second code block isn't working...

$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
Drew McLellan

Drew McLellan 2638 points
Perch Support

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...

array(2) { [0]=> array(28) { ["postThumb"]=> string(60) "/perch/resources/Blog/3683-0-full-izoard-febbraio08-3-95.jpg" ["postDesc"]=> string(389) "Gavia cutters omloop het volk gavia rochefort liege-bastogne-liege, contador the! Hors categorie autobus res firma mitescere nescit belleville colnago, ronde van belgie belleville coors classic criterium du dauphine ombregt paceline. Operacion puerto zabriskie col de perjuret venga venga venga battoowoo greekgreek rouleur derby, suitcase of courage up the on your left sanchez. Tenbosse." ["photoset-grid"]=> string(3) "213" ["photoset-images"]=> string(359) "" ["categories"]=> array(1) { [0]=> string(1) "1" } ["itemID"]=> string(1) "8" ["postID"]=> string(1) "8" ["postTitle"]=> string(13) "Rouleur Derby" ["postSlug"]=> string(24) "2014-10-15-rouleur-derby" ["postDateTime"]=> string(19) "2014-10-15 16:27:00" ["postDescRaw"]=> string(1155) "
Style Gavia cutters omloop het volk gavia rochefort liege-bastogne-liege, contador the! Hors categorie autobus res firma mitescere nescit belleville colnago, ronde van belgie belleville coors classic criterium du dauphine ombregt paceline. Operacion puerto zabriskie col de perjuret venga venga venga battoowoo greekgreek rouleur derby, suitcase of courage up the on your left sanchez. Tenbosse.

Lorem ipsum shut up legs bruges pereiro ronde van belgie cog, nokere koerse ghent anduze riis bonk? Hell of the north champs-elysees, bahati with molteni koppenberg feed zone milan-san remo, merckx leberg meyrueis gp ouest france plouay! Bruges bretagne echelon, chicane hoogerland van steenbergen thor smash coors classic de wolf, nys colnago a. Bottle cutters berendries in, giro belgium bruyneel sanchez an petacchi, molenberg palmares! Kleber pedaling squares reilhan parcours fabianese, cat among the pigeons rund um koln alpe d'huez feed zone once rouleur derby is for lovers. Flamme rouge groupo around gaul keirin e3 prijs vlaanderen, snob kluisberg cadence berg tilford. The druber ventoux, musette caravane cavendish gaul an ritte.

" ["postDescHTML"]=> string(1155) "
Style Gavia cutters omloop het volk gavia rochefort liege-bastogne-liege, contador the! Hors categorie autobus res firma mitescere nescit belleville colnago, ronde van belgie belleville coors classic criterium du dauphine ombregt paceline. Operacion puerto zabriskie col de perjuret venga venga venga battoowoo greekgreek rouleur derby, suitcase of courage up the on your left sanchez. Tenbosse.

Lorem ipsum shut up legs bruges pereiro ronde van belgie cog, nokere koerse ghent anduze riis bonk? Hell of the north champs-elysees, bahati with molteni koppenberg feed zone milan-san remo, merckx leberg meyrueis gp ouest france plouay! Bruges bretagne echelon, chicane hoogerland van steenbergen thor smash coors classic de wolf, nys colnago a. Bottle cutters berendries in, giro belgium bruyneel sanchez an petacchi, molenberg palmares! Kleber pedaling squares reilhan parcours fabianese, cat among the pigeons rund um koln alpe d'huez feed zone once rouleur derby is for lovers. Flamme rouge groupo around gaul keirin e3 prijs vlaanderen, snob kluisberg cadence berg tilford. The druber ventoux, musette caravane cavendish gaul an ritte.

" ["postDynamicFields"]=> string(2132) "{"postThumb":{"assetID":"78","title":"3683 0 full izoard febbraio08 3 95","_default":"\/perch\/resources\/Blog\/3683-0-full-izoard-febbraio08-3-95.jpg","bucket":"Blog","path":"3683-0-full-izoard-febbraio08-3-95.jpg","size":105749,"w":589,"h":800,"mime":"image\/jpeg","sizes":{"thumb":{"w":"110","h":"150","target_w":150,"target_h":150,"density":2,"path":"3683-0-full-izoard-febbraio08-3-95-thumb@2x.jpg","size":21394,"mime":""}}},"postDesc":{"raw":"Gavia cutters omloop het volk gavia rochefort liege-bastogne-liege, contador the! Hors categorie autobus res firma mitescere nescit belleville colnago, ronde van belgie belleville coors classic criterium du dauphine ombregt paceline. Operacion puerto zabriskie col de perjuret venga venga venga battoowoo greekgreek rouleur derby, suitcase of courage up the on your left sanchez. Tenbosse.","processed":"Gavia cutters omloop het volk gavia rochefort liege-bastogne-liege, contador the! Hors categorie autobus res firma mitescere nescit belleville colnago, ronde van belgie belleville coors classic criterium du dauphine ombregt paceline. Operacion puerto zabriskie col de perjuret venga venga venga battoowoo greekgreek rouleur derby, suitcase of courage up the on your left sanchez. Tenbosse."},"photoset-grid":"213","photoset-images":{"raw":"
<\/p>

<\/p>

<\/p>

<\/p>

<\/p>

<\/p>","processed":"

<\/p>

<\/p>

<\/p>

<\/p>

<\/p>

<\/p>"},"categories":["1"]}" ["postTags"]=> string(0) "" ["postStatus"]=> string(9) "Published" ["authorID"]=> string(1) "1" ["sectionID"]=> string(1) "1" ["postCommentCount"]=> string(1) "0" ["postImportID"]=> NULL ["postLegacyURL"]=> NULL ["postAllowComments"]=> string(1) "0" ["postTemplate"]=> string(9) "post.html" ["sortval"]=> string(1) "8" ["perch_postThumb"]=> string(60) "/perch/resources/Blog/3683-0-full-izoard-febbraio08-3-95.jpg" ["perch_postDesc"]=> string(389) "Gavia cutters omloop het volk gavia rochefort liege-bastogne-liege, contador the! Hors categorie autobus res firma mitescere nescit belleville colnago, ronde van belgie belleville coors classic criterium du dauphine ombregt paceline. Operacion puerto zabriskie col de perjuret venga venga venga battoowoo greekgreek rouleur derby, suitcase of courage up the on your left sanchez. Tenbosse." ["perch_photoset-grid"]=> string(3) "213" ["perch_photoset-images"]=> string(359) "" ["perch_categories"]=> array(1) { [0]=> string(1) "1" } } ["html"]=> string(2890) "
EVENTS

Rouleur Derby
WEDNESDAY, OCTOBER 15, 2014
Style Gavia cutters omloop het volk gavia rochefort liege-bastogne-liege, contador the! Hors categorie autobus res firma mitescere nescit belleville colnago, ronde van belgie belleville coors classic criterium du dauphine ombregt paceline. Operacion puerto zabriskie col de perjuret venga venga venga battoowoo greekgreek rouleur derby, suitcase of courage up the on your left sanchez. Tenbosse.

Lorem ipsum shut up legs bruges pereiro ronde van belgie cog, nokere koerse ghent anduze riis bonk? Hell of the north champs-elysees, bahati with molteni koppenberg feed zone milan-san remo, merckx leberg meyrueis gp ouest france plouay! Bruges bretagne echelon, chicane hoogerland van steenbergen thor smash coors classic de wolf, nys colnago a. Bottle cutters berendries in, giro belgium bruyneel sanchez an petacchi, molenberg palmares! Kleber pedaling squares reilhan parcours fabianese, cat among the pigeons rund um koln alpe d'huez feed zone once rouleur derby is for lovers. Flamme rouge groupo around gaul keirin e3 prijs vlaanderen, snob kluisberg cadence berg tilford. The druber ventoux, musette caravane cavendish gaul an ritte." }

Drew McLellan

Drew McLellan 2638 points
Perch Support

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.