CMS Made Simple Forums
https://forum.cmsmadesimple.org/

cmsms content_en only display specific html tags???
https://forum.cmsmadesimple.org/viewtopic.php?f=20&t=79526
Page 1 of 1

Author:  Sendlingur [ Mon Dec 10, 2018 4:09 pm ]
Post subject:  cmsms content_en only display specific html tags???

I'm not using the wysiwyg editor on my content pages there for my content pages looks like this.

Code:
<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 :
Quote:
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?

Author:  DIGI3 [ Mon Dec 10, 2018 4:33 pm ]
Post subject:  Re: cmsms content_en only display specific html tags???

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:
{$content={page_attr key=content_en}
{strip_tags($content,"<p>")}

You'll probably need permissive Smarty enabled in your config.

Author:  velden [ Fri Dec 14, 2018 12:23 pm ]
Post subject:  Re: cmsms content_en only display specific html tags???

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:
<__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:
...
{content block=intro label='Introduction' assign=intro}
{if $intro != ''}
  <div class="intro">
     {$intro}
  </div>
{/if}
...


and template inheritance etc etc.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/