10 years ago
Topic
Hi, I am using the Seb_minima template so that I have more control over the layout of my search results and wonder if there is a way in the search results to limit the amount of characters displayed from a text area field or WSIWYG field so that I can add a read more afterwards and make it all look neat and tidy. Obviously I cant use the Intro text table since Seblod is using it. Help is greatly appreciated, i realise that this may even be a php question more than a Seblod question.
Get a VIP membership
175 Posts
webcastor
10 years ago
0
Level 1
I might suggest SD Databaser typography on an article id field. That way you can just query something like: SELECT left (description,200) as description FROM #__content WHERE id = *value*;
However, your text should be stored as plain text, since there is no easy way to insure there won't be unclosed HTML tags. Also, Seblod is using introtext field for it's inner functioning, so some other field should be preferred, since strip_tags will not affect ::cck::xx::/cck:: part (and I don't think you want that).
Also, you can do a position override in template and perform strip_tags($cck->getValue('fieldName')) or maybe strip_tags($cck->renderField('fieldName')). Since in this case you would be using a result - text obtained by typography "overlay", I think you need renderField variant. Also, avoid field labels (because renderField will obviously render it). Just insert "clear" (without quotes) as the field label. There is also the $cck->getTypo which you might use.
175 Posts
webcastor
10 years ago
0
Level 1
If you decide to go the template override route, you might even include the complete Article Introtext field (in Item view), and in override specify something like:

$introShort = left( strip_tags( $cck->getValue('art_introtext') ), 200);

The override will be in /templates/templateName/positions/contentType/item/ folder.
10 years ago
1
Level 1
Hi Webcaster, your help is greatly appreciated. I tried for a few hours to get the SD Databaser method to work without success. My first problem was trying to apply it to the Article ID field in "Search and list's" Item, that didnt work at all so i tried to apply it to the Article ID field in Intro in the "form and content type" using:
SELECT left (fulltext,200) as fulltext FROM #__content WHERE id = *value*; (Column as value=fulltext)
This kept giving me an sql error but from the error i could see the *value* was succesfully replaced with the ID number. in the end i went back to the drawing board and found this article;
http://www.seblod.com/v2/forum/Content-Types--Forms/38622-How-to-limit-the-size-of-article-introtext.html

Just incase this above url ends up 404ing like so many other links are that I have come across in the Seblod2 Forum im going to repeat unleash.it method here in the new v3 forum...

Since I am using the Seb_Minima template for my search result ITEMS and for my Form INTRO but Seb_blog for my forms i place this into the templates/seb_blog/config.php file;
<?php function trim_trim($input, $length, $ellipses = true, $strip_html = true) { //strip tags, if desired if ($strip_html) { $input = strip_tags($input," *list your html tags to strip here*"); } //no need to trim, already shorter than trim length if (strlen($input) <= $length) { return $input; } //find last space within length $last_space = strrpos(substr($input, 0, $length), ' '); $trimmed_text = substr($input, 0, $last_space); //add ellipses (...) if ($ellipses) { $trimmed_text .= '...'; } return $trimmed_text;} ?>

And call it in my search results here templates/seb_minima/positions/XX/item/mainbody.php
using <?php get('field_name')->value, 230, $ellipses = true, $strip_html = TRUE);?>

I hope this helps someone else save the many hours I have spent and thank you again for your help Webcaster.


10 years ago
0
Level 2
Thinking about it, adding the trim_trim function to templates/seb_blog/config.php will probably get overwritten in a Seblod update so this might not be the best place to add it.
175 Posts
webcastor
10 years ago
1
Level 1
You can also consider PHP String Typography Plugin. It will allow you to do exactly what you wanted, to perform a substr on your content, specifying the start and length of your text. You can even specify Prefix and Suffix. I have tested it on Intro layout with Seblod HTML and Seblod Minima templates. I will test it on a List&Search layout, but so far I am confident it will work.
10 years ago
0
Level 2
Thanks, ill give that a try too. I think the long and short of it is that i really need to learn some php. Thanks so much for your help Webcaster.
175 Posts
webcastor
10 years ago
1
Level 1
As much as I agree on the need to know PHP argument, you do not need it with the mentioned plugin. Just visit the link, download, install, set as typography to introtext field, set the start and length, and - vuala... it just works.
10 years ago
0
Level 2
Yup it is a breeze and it does work in a List&Search field, thanks AGAIN for the heads up. Now im off to see what the other functions are that it can do so I know what new tools I have in my arsenal. Happy days.
Get a Book for SEBLOD