Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

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

Teaser Content and security


Reply


7 Posts   532 Views

Avatar
OZROD

Community Member, 6 Posts

31 December 2013 at 12:24am

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 :-)

Avatar
Nivanka

Community Member, 400 Posts

31 December 2013 at 4:55am

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

Avatar
camfindlay

Forum Moderator, 185 Posts

31 December 2013 at 11:48am

Edited: 31/12/2013 11:49am

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.

Avatar
OZROD

Community Member, 6 Posts

2 January 2014 at 12:06am

Hi Guys,

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

Avatar
OZROD

Community Member, 6 Posts

2 January 2014 at 10:53pm

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

Avatar
martimiz

Forum Moderator, 1132 Posts

3 January 2014 at 12:48am

Edited: 03/01/2014 12:48am

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

Avatar
OZROD

Community Member, 6 Posts

2 July 2014 at 5:37pm

Cheers for that martimiz!

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