I have a project where the client only wants to show partial bits of content on different pages dependent on if a user is authenticated or not. There may be several partial bits per page so I can't just use a 'preview' or ellipsis filter.
So I cobbled together this from some stackoverflow and examples:
<?php
$output = '';
$dom = new domDocument('1.0', 'utf-8');
$dom->loadHTML($content);
$dom->preserveWhiteSpace = false;
$xPath = new DOMXPath($dom);
$nodes = $xPath->query('//span[@class="preview"]');
if($nodes->length == 0){
$output = $content;
}else{
foreach($nodes as $node){
$output .= '<p class="preview">'.$node->nodeValue.'...<a href="[[~'.$formid.']]" >read more</a></p>';
}
}
return $output;
I'm calling it like this for now:
[[ParseContent? &content=`[*content]` &formid=`1` ]]
Works just peachy [minus the authentication part - not built in yet]
HOWEVER
When I come across a page that has a call to formit, it breaks down & I get no content.... is there a way I can determine if a [[*content]] variable has a formit call in it ~ before ~ I try to process the content?
[ed. note: sean69 last edited this post 14 years, 4 months ago.]
*** Not just websites, we also create signage, banners, print, trade show displays and more! ***
Sean Kimball CLP, CLS.
Technical Director / Sr. Developer | BigBlock Studios
._______________________________________________.
Bigblock Studios
http://www.bigblockstudios.ca Web site design & development.
27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
phone/fax: 905-426-5525