Jump to content

This topic is 7102 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted (edited)

Hi All.

I'm having a small problem with showing only part of a text on a lasso-page.

I have a database with a field that contains quite a lot of text. I would like to only show the first 40-50 words and then a link to view the hole text on another page. Like most news pages that shows only a part of the news text and then a link to read more. Haven't been able to get it to work.

Have never worked with the strings tag (witch I think is the one to use but I'm not sure) Can anyone help?

Thanks in advance...

The Dog

Edited by Guest
Posted

To show the first part of the text, create a calculation field.

To get the first 50 words, the formula is:

LeftWords(textfield;50)

To get just the paragraphs within the first 50 words:

LeftValues(textfield;PatternCount(LeftWords(textfield;50);¶))

To get the sentences within the first 50 words:

Left(textfield;Position(textfield;".";1;PatternCount(LeftWords(textfield;50);".")))

Posted

Thanks dwins

But the method you outlined takes a database change and an update of the databases. And everytime I have to change anything in the databases I have to pay about 200 dollars to my host... So if anyone knows how to do this in the lasso file (I know it possible) I would be very greatful.

The Dog

Posted (edited)

Woof! I'm afraid I don't have Lasso and you can already see similar logic w/dwins calc field suggestion, but in PHP it'd be something like....

$article = "[Field:fullstory]";

$intro = substr("$article", 0, 250);

print ("$intro... ");

print ("[MORE]");

I haven't done this; it's only what I think I'd try, so I cannot vouch for it. Plus, I'd be limiting based on 250 characters instead of 40-50 words, but I suppose I could count spaces and use another function. Try to use this kind of logic to the Lasso equivalent. Or post the Lasso info and syntax on the Lasso strings tags and I or someone else can do better.

Lasso should have something like [Left(field:fullstory, 0, 250)] or somesuch similar. Or maybe one of the Lasso folks will jump in here and just say, "Oh, that's easy... it's just...".

--ST

Edited by Guest
missing ' in code
Posted

Hi Steve

Thanks for your tips.

It helped my get to this:

[var: 'newsString' = (field: 'text', -EncodeBreak)]

[($newsString)->(substring: 1, 300)]

And shows only the first 300 lettes of the text.

That fine.... but I would love to be able to cut the text after a word count not based on letters as it cuts the text (sometimes) in the middle of a word.

Thanks again

This topic is 7102 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.