Jump to:

10929 Posts in 2613 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » Teaser Content and security

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 362 Views
  • OZROD
    Avatar
    Community Member
    6 Posts

    Teaser Content and security Link to this post

    Hi Guys,

    I would like to create content with two paragraphs, the first paragraph (short) will be a teaser with a "read more" linke. However, on click of read more i'd like to force the user to login in order to read the second bit of text. Does such already exist? if not, how would i go about it? i'm pretty new with SS.

    Cheers

  • Nivanka
    Avatar
    Community Member
    395 Posts

    Re: Teaser Content and security Link to this post

    You can easily add two HTMLText fields to the page (DataObject)

    static $db = array(
    "MoreContent" => "HTMLText"
    );

    http://doc.silverstripe.com/framework/en/topics/page-types

    this link will help.

    and then use jQuery to slide up / slide down the more content on a toggle action

  • camfindlay
    Avatar
    Forum Moderator
    146 Posts

    Re: Teaser Content and security Link to this post

    To allow only the second paragraph to be read when a Member is logged in you could wrap the paragraph in the SilverStripe template engine tags

    <% if $CurrentMember %>
    . . .

    Paragraph goes here

    . . .
    <% else %>

    You could add a message and link here to get the user to log in.

    <% end_if %>

    See http://doc.silverstripe.org/framework/en/reference/templates#conditional-logic for more information about conditional logic in the templates.

  • OZROD
    Avatar
    Community Member
    6 Posts

    Re: Teaser Content and security Link to this post

    Hi Guys,

    That's great! thank you heaps and Happy New Year!!

  • OZROD
    Avatar
    Community Member
    6 Posts

    Re: Teaser Content and security Link to this post

    Post New Years thoughts... and more questions

    Another question regarding secured content and also applicable to other content. Is it possible to use "shortcodes" to embed content from other pages onto an existing page? from the text editor as opposed to be programming something specifically?

    I'm looking to replace a custom CMS with SilverStripe. The system in question allows users to add any type of content onto a page, including secured content with teaser text and alter the position on the page. All this is done from the page itself, just can't think of a way as yet with my limited knowledge of SS how I'd go about achieving the same result.

    Rodrigo

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Teaser Content and security Link to this post

    Yes, you can use shortcodes in SilverStripe. In your HTML editor it might basically look something like:

    [Teaser,id="17"]

    Of course that wouldn't work out of the box, but he documentation will tell you the basics about how to write a a shortcode handler for it:

    http://doc.silverstripe.org/framework/en/reference/shortcodes

    The handler would then retreive the first paragraph of the content of the page with id = 17...

  • OZROD
    Avatar
    Community Member
    6 Posts

    Re: Teaser Content and security Link to this post

    Cheers for that martimiz!

    Hadn't seen your reply earlier... I'll be getting getting back to this soonish.

    362 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.