Advertisement:

Author Topic: Text Formatting problem  (Read 1345 times)

thiru_ch

  • Jr. Member
  • **
  • Posts: 75
Text Formatting problem
« on: July 28, 2014, 12:36:51 pm »
Hi, I used certain formatting effects for description of the add. But those formatting effect are not displaying on home in latest Listings. But those are displaying in the item view. So i want to display the formatting effects at front page and search results also.
I am uploading the screen shots.

please help me regard this matter

aide2001

  • Guest
Re: Text Formatting problem
« Reply #1 on: July 28, 2014, 01:19:16 pm »
This is because on item the description etc is echo'd differently than from the latest listings echo
It depends on what theme you use, but the clue is to look at item.php and compare that to the latest listings and or main or where ever you have the latest listed items

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Text Formatting problem
« Reply #2 on: July 28, 2014, 01:24:02 pm »
Hi,

Yes, on search views description is purged of HTML tags, look for something like this in your search-list.php (or similar, it depends on the theme you're using). ???

Code: [Select]
osc_highlight( strip_tags( osc_item_description()) ,250)
and replace it with

Code: [Select]
osc_highlight( osc_item_description() ,250)
Regards

thiru_ch

  • Jr. Member
  • **
  • Posts: 75
Re: Text Formatting problem
« Reply #3 on: July 29, 2014, 05:31:37 pm »
@ teseo,
Thank you for your reply.
I tried it but it is not working.
I am using alterego which is based on modern theme.
is there any other method?
...
thiru

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Text Formatting problem
« Reply #4 on: July 29, 2014, 07:20:07 pm »
Yes, I can see what's happening now. This Modern vanilla code:

osc_highlight( strip_tags( osc_premium_description() ) )

really doesn't need to include function strip_tags, because osc_highlight() already includes it. Then the solution is to clone osc_highlight() and modify it a little to not apply strip_tags.

Add this at the very bottom of your theme functions.php (take care not to leave blank lines after this):

Code: [Select]
<?php
/**
 * Gets prepared text, with:
 * - higlight search pattern and search city
 * - maxim length of text
 * - Preserve HTML tags (teseo's mod)
 *
 * @param string $txt
 * @param int  $len
 * @param string $start_tag
 * @param string $end_tag
 * @return string
 */
function cust_highlight($txt$len 300$start_tag '<strong>'$end_tag '</strong>') {
    
// $txt = strip_tags($txt); // Only difference with cloned core helper osc_highlight()
    
$txt str_replace("\n"' '$txt);
    
$txt trim($txt);
    if( 
mb_strlen($txt'utf8') > $len ) {
        
$txt mb_substr($txt0$len'utf-8') . "...";
    }
    
$query osc_search_pattern();
    
$query str_replace(array('(',')','+','-','~','>','<'), array('','','','','','',''), $query);

    
$query str_replace(
        array(
'\\''^''$''.''[''|''?''*''{''}''/'']'),
        array(
'\\\\''\\^''\\$''\\.''\\[''\\|''\\?''\\*''\\{''\\}''\\/''\\]'),
        
$query);

    
$query preg_replace('/\s+/'' '$query);

    
$words = array();
    if(
preg_match_all('/"([^"]*)"/'$query$matches)) {
        
$l count($matches[1]);
        for(
$k=0;$k<$l;$k++) {
            
$words[] = $matches[1][$k];
        }
    }

    
$query trim(preg_replace('/\s+/'' 'preg_replace('/"([^"]*)"/'''$query)));
    
$words array_merge($wordsexplode(" "$query));

    foreach(
$words as $word) {
        if(
$word!='') {
            
$txt preg_replace("/(\PL|\s+|^)($word)(\PL|\s+|$)/i""$01" $start_tag "$02"$end_tag "$03"$txt);
        }
    }
    return 
$txt;
}

?>

Then you replace in Modern search-list.php:

osc_highlight( strip_tags( osc_premium_description()) )
and
osc_highlight( strip_tags( osc_item_description()) )

with

cust_highlight( osc_premium_description() )
and
cust_highlight( osc_item_description())

Try and see if it doesn't need some other adjustment. ???

Regards

thiru_ch

  • Jr. Member
  • **
  • Posts: 75
Re: Text Formatting problem
« Reply #5 on: August 05, 2014, 08:37:37 am »
@teseo,

I tried your suggestions but the problem is not solved. So please tell me if there is any other method.
..
Thiru

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Text Formatting problem
« Reply #6 on: August 05, 2014, 10:53:57 pm »
It's working for me on Modern theme, an there's no other way around.

Regards