Please read and follow the COMMON ISSUES first!
Always add your version information in every new post! Thank you!

Form2Content Forum

Questions and answers for Form2Content, a Joomla CCK.
  1. Marc
  2. F2C submission form templating
  3. Thursday, 06 April 2017
  4.  Subscribe via email
Hi, is there a way to strip html comment from the template when the article is submitted?
I've made a plugin but no luck…


public function OnAfterF2cContentSave($eventData)
{

$strIntro = $eventData->parsedIntroContent;
$strMain = $eventData->parsedMainContent;

/* strip html comments*/
$re = '/<!--.*?-->/s';
$subst = '';
$resultIntro = preg_replace($re, $subst, $strIntro);
$resultMain = preg_replace($re, $subst, $strMain);

$eventData->parsedIntroContent = $resultIntro;
$eventData->parsedMainContent = $resultMain;

// print_r($str);die();

return true;
}


thanks
Accepted Answer
F2C webmaster Accepted Answer Pending Moderation
Just did some Googling and found Smarty comments. {* comment *}.
http://www.smarty.net/docsv2/en/language.basic.syntax.tpl

What I don't get is. Why add html comments if you don't want them in your html??
Please read the F2C documentation before asking questions! Thank you if you've done so ;)
Responses (4)
F2C webmaster Accepted Answer Pending Moderation
Hi Marc,

You can strip html tags on any entered data using a Smarty modifier.
http://www.smarty.net/docsv2/en/language.modifier.strip.tags.tpl

So if you have an editor field called Description and you just want to render text without any html you add this to your template:

{$DESCRIPTION|strip_tags}

Hope this is what you are looking for.

Regards,
Patrick
Please read the F2C documentation before asking questions! Thank you if you've done so ;)
Marc Accepted Answer Pending Moderation
Hi Patrick,
Thanks but no, it isn't what I want to achieve.

I have some html comments in my f2c templates (xxx.tpl) and I would like to keep them in the templates for clarity but strip them when the content is parsed to the actual joomla article.

Regards,
Marc
Marc Accepted Answer Pending Moderation
Well, thanks Patrick, that's it.

What I don't get is. Why add html comments if you don't want them in your html??


for the very reason that you can found in the smarty page you've linked :

"Smarty comments are NOT displayed in the final output of the template, unlike <!-- HTML comments -->. These are useful for making internal notes in the templates which no one will see ;-)"

Regards,
Marc
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.