cmsms content_en only display specific html tags???

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Locked
Sendlingur
Forum Members
Forum Members
Posts: 60
Joined: Wed Aug 08, 2018 4:59 pm

cmsms content_en only display specific html tags???

Post 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?
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1059
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

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

Post 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.
Not getting the answer you need? CMSMS support options
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3293
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

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

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

Return to “Layout and Design (CSS & HTML)”