Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

How to create "Read more" button

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
solanrume
Smarty n00b


Joined: 28 Jul 2019
Posts: 1

PostPosted: Sun Jul 28, 2019 10:10 am    Post subject: How to create "Read more" button Reply with quote

Hi everybody, I'm newbie. I want to create "Read more" button , it displays 45 characters and then expands when you click the 'Read more' button. Can you give me some suggestions?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1577

PostPosted: Wed Jul 31, 2019 11:28 am    Post subject: Reply with quote

Smarty don't control any buttons. By the time your code is displayed in the Browser, Smarty had already finished its work and is long gone already.
What you will need is CSS "overflow" attribute, and some JavaScript automation to drive your page layout, that will help.
Back to top
View user's profile Send private message
pedrotester
Smarty Rookie


Joined: 06 Jun 2019
Posts: 23

PostPosted: Fri Aug 16, 2019 8:03 pm    Post subject: Reply with quote

you can use
Quote:
|truncate
modifier
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1577

PostPosted: Wed Aug 21, 2019 8:18 am    Post subject: Reply with quote

pedrotester wrote:
you can use
Quote:
|truncate
modifier

That would be the worst possible solution.
Back to top
View user's profile Send private message
pedrotester
Smarty Rookie


Joined: 06 Jun 2019
Posts: 23

PostPosted: Wed Aug 21, 2019 5:54 pm    Post subject: Reply with quote

Why is it worse than cropping it with CSS? I can do both but I chose truncate. I mean in the case where you have to click "read more" and it opens a new page, not display the whole text.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1577

PostPosted: Thu Aug 22, 2019 4:59 am    Post subject: Reply with quote

CSS does not crop, it hide the content from view, but it's still present on the page.
I.e. search engine bots will see full text, rather than ellipsized version like in your case.
And you don't need to open new page, just change CSS attribute, to see full text.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP