Need help with word string length

Can someone tell me how to return let say 100 words and not all the words from my database table? I am not sure how to accomplish this in Wappler or how to use the php strlen() statement in Wappler to accomplish this or whatever method is used.

I just want to return only the first 100 words from my comments table in a Card then have a read more button that will show all the comments once click. Thanks
@George @Teodor @Hyperbytes

Two ways you can do this easily

  1. Use a custom query and use the SQL left function. The standard query does not support sql functions directly

Something like

SELECT LEFT(“mydata”, 100) as ShortComment WHERE …

Alternatively return the full comment from server connect and use app connect to only display the first 100 characters with the subs function i.e. mycomment.substr(0, 100). More data initially but you then already have the full text ready for the “read more” feature

There is also a truncate formatter, which can be used to show the first X characters of your content.

2 Likes

Didn’t know that one Teodor, I assumed it just worked like trim and removed spaces. Another really useful tool

truncate works! Boy oh boy. every time I get a solution to these problem I feel like running around my block saying yes! :clap:. Thanks a lot guys.

So, I have another issue but its about the medium editor I have been try to figure how to get it working and I just cannot figure out how to get it working (I have turn textarea into medium editor in my forms upload a dozen time now) so it will format my home page area both when I insert into my database and querying back the info lets say to a section on home page with the formatted text and image etc. But it just turn the textarea into medium editor and nothing get uploaded when I submit the form.
image#1.


image#2.

So basically I want to turn image#2 update form into a medium editor but I would like step by instruction of how to make the whole thing work from inserting it to my database starting from image#1 and updating it again at image#2.

Please I have tried everything and watch every dmx zone video out there on this and there is just not enough instructions on how to get this simple task done. Please help me if you can.

So if i understand correctly you want to know how to bind the modal content to a specific table list item when clciked, display that detail and then save any changes made via the update form in the modal

If so, I suggest you view the YouTube video " Webinar 2 - Building a contact Manager App" below which details that technique and many more edit/ update/ delete techniques and should clarify everything you need.

And the good thing about the Truncate formatter is it doesn’t show half a word.

@Hyperbytes the problem I am having is with the medium editor. I need a demo on how to get it working for example how to implement it the form textarea so it will work once I submit the form to my database/retrieving back the formatted content. I have watched all the dmxzone videos and turn textarea into medium editor a dozen time now, but When I type content plus add video in the medium editor area and submit the form this is where I need help on how this is done correctly. I need to basically know how to get it working on the server side/getting back that info on a section on my home page, and there is not a lot of info on the Wappler documentation on how get medium editor working with server side. So from my images in my prior note this is what I need help with.

Love your videos by the way they helped me a lot.

Medium editor works with the insert and update record forms absolutely the same as any other form input.

Do you think you could do a demo video for me showing how to get it upload to a database table with images/ wording and then querying that formatted info from the database on a page. I have tried doing it a few times and I believe I might be doing something wrong. If not can you point me in a direction on how to do this correctly. Thanks a lot @Teodor I know I am asking a lot right now and I appreciate all the help I can get.

So is the issue saving the text or loading the video?

Saving the text is exactly the same as a textarea, absolutely no difference. Upload needs an additional server action to do the upload

1 Like

The issue is kinda both. When I turn textarea into medium editor for upload it to my database table I must be doing something wrong because the formats does not hold when I query the info a on a different page and when I create the update actions form with medium editor to edit that same content the medium editor does not return any content when I add medium editor to my update query form.

So, basically I want to use medium editor in my insert form to edit content and I want to use it back again in my update form to edit that same content it suppose to retrieve. that part I need help with or a demo on how to do.

It is EXACTLY the same as using a standard update form, medium edit just produced a textarea with html codes inserted

Just set the medium editor field to the record content (attributes -> value) and in the save server action just update the field from the $_POST variable

I will probably do a tutorial on this at some point (it is in my list) but I am, so busy with my own work i can hardly keep up with that at the moment so it wont be for a while

1 Like

I totally understand @Hyperbytes. willl give this a try one more time and see if I get a better result.