result list file names truncated

Home Forums Product Support Forums Ajax Search Pro for WordPress Support result list file names truncated

This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 2 years, 6 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #26337
    nathan96753
    nathan96753
    Participant

    Greetings,

    We are using AjaxSearch on https://makenasurf.org/historical-meeting-minutes/

    In the results list, file names are often truncated, usually at the first ‘.’ character. We need the results list to show the complete file names:

    In the attached screenshot, in a search for ‘Nathan’. the fourth result shows “Makena-Surf-Annual-2019” when it should show “Makena-Surf-Annual-2019.02.23-draft” ( the file name is Makena-Surf-Annual-2019.02.23-draft.pdf )

    Any help or advice is appreciated.

    Stay safe and healthy !

    Best,
    Nathan

    Attachments:
    You must be logged in to view attached files.
    #26343
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    The plugin does not truncate the titles. The issue is, that wordpress automatically generates the attachment titles, and it truncates the file extensions. The plugin then requests this title, it is already stored that way. I think there is still a way to get the file name based on the storage path and override the titles in the results via custom code.
    Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

    add_filter( 'asp_results', 'asp_get_file_name_res', 10, 1 );
    function asp_get_file_name_res($results) {
    	foreach ( $results as $k => &$r ) {
    		if ( $r->content_type == 'attachment' ) {
    			$r->title = basename ( get_attached_file( $r->id ) );
    		}
    	}
        return $results;
    }

    I could not test this code, so please be careful. Hopefully it should change the titles in the live results list.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #26573
    nathan96753
    nathan96753
    Participant

    Thank You Ernest,

    We tried this Conde and didnt see any difference in the results list. This is curious because it worked fine up to about 3 months ago.

    Any other suggestions for us?

    Thanks and stay safe!

    Best,
    Nathan

    #26577
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Nathan,

    Wordpress most likely changed something there, there was no change in our plugin, regarding the titles.

    Using the custom code is the only option here I’m afraid. If you want, you can add temporary FTP details, and I will try to test it out.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.