Page 1 of 1

cmsms content_en only display specific html tags???

Posted: Mon Dec 10, 2018 4:09 pm
by Sendlingur
I'm not using the wysiwyg editor on my content pages there for my content pages looks like this.

Code: Select all

<section class="text-section type2">
			<div class="container animation-top">
				<h2>{title}</h2>
				<p>some content text ...</p>
</div>
</section>
in my search results page I use {page_attr key=content_en} to display the content below the corresponding title.

the problem is that in the search results the {content_en} displays the results like :
page title
{title} some content text ...
Obviously I dont wan't to display the {title} tag, I just need to be able to display what is inside the <p> tags.

Is there a way to let the content_en skip reading the <h2> tags and only read the <p> tags?

Re: cmsms content_en only display specific html tags???

Posted: Mon Dec 10, 2018 4:33 pm
by DIGI3
This is where separating content from markup is a good idea. Move the title and html to your template, and use the content block for content only. Use template inheritance if your pages need different formatting.

If you're not willing to do that, you can use php functions in Smarty. Something like:

Code: Select all

{$content={page_attr key=content_en}
{strip_tags($content,"<p>")}
You'll probably need permissive Smarty enabled in your config.

Re: cmsms content_en only display specific html tags???

Posted: Fri Dec 14, 2018 12:23 pm
by velden
Like DIGI3 says.

If you're new to CMSMS and/or smarty you may not realize you can add multiple content blocks to a page template:

Code: Select all

<__html>
  ...
  </__body>
     <h1>{title}</h1>
     <h2>{content block=subtitle label='Subtitle' oneline=true}</h2>
     <div class="intro">{content block=intro label='Introduction'}</div>
     <div class="main">{content label='Default content block'}</div>
  <__body>
</__html>
This is just a vary basic example, you can do much more using e.g. assignment to variables and use it conditionally

Code: Select all

...
{content block=intro label='Introduction' assign=intro}
{if $intro != ''}
  <div class="intro">
     {$intro}
  </div>
{/if}
...
and template inheritance etc etc.