by gobezu » Mon Oct 26, 2009 7:23 am
i have failed to make the plugin load with the current code and just wanted to report back with a version that works (at least for me) which is found further down
- Code: Select all
function onPrepareContent( &$article, &$params, $limitstart )
{
$regex = '/{ckform\s*(.*?)}/i';
// find all instances of plugin and put in $matches
preg_match_all( $regex, $article->text, $matches );
// Number of plugins
$count = count( $matches[0] );
if ($count > 0) {
foreach ($matches[1] as $i => $textFound) {
// Load Selected form
$form = $this->loadCkForm($textFound);
if ($form == null)
{
$html = "<span style='color: #FF0000'>CKForms Error Message : <br />Form '" . $textFound . "' not found !!!</span>";
$article->text = str_replace($ckFormTag, $html, $article->text);
return;
}
$fields = $this->loadCkFormFields($form->id);
$_SESSION['ck_send_once'.$form->id] = "1";
$this->formLink = "index.php?option=com_ckforms&view=ckforms&task=send&id=".$form->id;
$html = $this->generateCkFormHTML( $form, $fields);
$article->text = str_replace($matches[0][$i], $html, $article->text);
}
}
}