popularanky
Posts: 53
|
| Posted: 09/21/2010, 7:06 AM |
|
I have a grid field for news and I want to reduce the characters to 100 with a "Read More" link, so that users can click on the link to read the full news.
_________________
EKERE UBONG UBONG
IT Officer
CognitiveDrive |
 |
 |
datadoit
|
| Posted: 09/21/2010, 7:18 AM |
|
What's your environment? Language and database.
|
|
|
 |
popularanky
Posts: 53
|
| Posted: 09/21/2010, 7:53 AM |
|
I am using CCS 4.3, PHP MYSQL
_________________
EKERE UBONG UBONG
IT Officer
CognitiveDrive |
 |
 |
solesz
Posts: 137
|
| Posted: 09/22/2010, 1:04 AM |
|
Hello,
I propose to create a separate field in your database for the summary text then when you display you can put a link to view more.
When visitor clicks view more link, you can redirect him into a page where summary text and article body is composed together as a simple block.
This soluiton let you control how do you want to catch your visitor attention - with a summary text - , and there is no need to find out logic and program it which can cut your text into two parts, at the right place (will be understable after cutting, cut not within a nbsp sign... etc.)
solesz
datadoit: I think the base solution is language and database independent...
|
 |
 |
popularanky
Posts: 53
|
| Posted: 09/22/2010, 1:23 AM |
|
I have been doing that, but the problem here is that this process the users has to input the sentences ,so I don't have control over their length of input and I don't want to stop the length of sentence. and also don't want to give them two fields for same values. I just want the same control Facebook uses for comment reduction.
_________________
EKERE UBONG UBONG
IT Officer
CognitiveDrive |
 |
 |
MaFi
Posts: 49
|
| Posted: 09/22/2010, 2:04 AM |
|
why don't you use MySQL Function LEFT(str,len) ?
SELECT LEFT(Field1, 100) AS NewField FROM Table1
|
 |
 |
popularanky
Posts: 53
|
| Posted: 09/22/2010, 2:21 AM |
|
hOW CAN i INCLUDE THIS INTO MYSQL OR CCS?
_________________
EKERE UBONG UBONG
IT Officer
CognitiveDrive |
 |
 |
MaFi
Posts: 49
|
| Posted: 09/22/2010, 11:52 PM |
|
You can use the Visual Query Builder in CCS to specify the the field LEFT(Field1, 100) in the SELECT area under Column/Expression and NewField in the Alias .
|
 |
 |
datadoit
|
| Posted: 09/23/2010, 6:20 AM |
|
For your data column's label, we'll call it Lbl_News, in the Server ->
Before Show for the label, add custom code:
if (strlen($Component->GetValue()) > 100)
{
$Component->SetValue(substr($Component->GetValue(),0,100) . " ... [<a
href='YourMorePage.php?'" . CCGetQueryString("QueryString","") . "
alt='' title='Click to read more.'>more</a>]");
}
Make sure Lbl_News' Content property is changed from the default Text to
HTML.
See http://www.php.net/manual/en/ref.strings.php for more wonderful
string functions.
|
|
|
 |
CodeChargeMVP
Posts: 473
|
| Posted: 09/23/2010, 6:51 AM |
|
There many possible solutions,
javascript and Visual query builder seems the faster and easiest.
_________________
Best Regards
Entrepeneur | NT Consultant
|
 |
 |