-
AuthorPosts
-
August 25, 2020 at 5:20 pm #1240715
Hi,
Stéphane Bouey from Faboba has been working at my request to get the Falang Multilanguage System for WordPress working nicely with all things Enfold. It’s now working very well for all items, including a language switcher in every Enfold menu position. He will publish the new version of Falang 1.3.2 with all the fixes for Enfold soon.
There was one item remaining, the Blog Magazine layout would not show the translations of the excerpts.
To fix that he needed to make a change to Enfold’s magazine.php, line 1236:$excerpt = ! empty( $entry->post_excerpt ) ? get_the_excerpt($entry->ID) : avia_backend_truncate( apply_filters('avf_magazine_entry_content',$entry->post_content,$entry), apply_filters( 'avf_magazine_excerpt_length', 60 ), apply_filters( 'avf_magazine_excerpt_delimiter', ' ' ), '…', true, '' );
To make the change survive future updates we added the change to the child theme functions.php like this:
// override magazine.php from parent theme in the child theme // change by Stéphane Bouey for Falang to translate excerpts in Magazine Blog // Added new folder in child theme directory called avia-shortcodes // Copied element from enfold/config-templatebuilder/avia-shortcodes/magazine to this folder // it will replace the one in the parent and be used from the child theme instead // added the following function to child theme’s functions.php: add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1); function avia_include_shortcode_template($paths) { $template_url = get_stylesheet_directory(); array_unshift($paths, $template_url.'/avia-shortcodes/'); return $paths; }
2 questions:
– is this the best way to override the magazine.php from the parent theme?
– is the filter added to the magazine.php something to add maybe to Enfold itself? I imagine it could be needed also for other translation plugins?Thanks for your help,
RobAugust 31, 2020 at 2:39 am #1242039Hey Rob,
Sorry for the late reply, and thanks for the heads up about Falang multilanguage for WordPress, it will be interesting to check out the update.
As far a customizing an element for your child theme, we recommend that you follow these steps, create a directory in your child theme called “/shortcodes/” and then add a copy of the directory from “/enfold/config-templatebuilder/avia-shortcodes/magazine/” and edit the magazine.php to suit.Now if you are using the pre-built child theme that should have been included with the last couple on versions, it will recognize that the child theme “/shortcodes/” directory is available and load any elements inside (avia-shortcodes).
The function that does this is:function avia_include_shortcode_template( $paths ) { if( ! is_array( $paths ) ) { $paths = array(); } $template_url = get_stylesheet_directory(); array_unshift( $paths, $template_url . '/shortcodes/' ); return $paths; } add_filter( 'avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1 );
Here is our documentation.
If you built your own child theme then please add this function instead.Best regards,
MikeAugust 31, 2020 at 8:16 am #1242063Hi Mike,
Thanks for the answer. What about question number 2?
Here’s what Stéphane mentioned:
The change in magazine.php is needed because at the moment in the parent theme Enfold uses the post_content (when no manual excerpt exists) but for excerpt and post_content it doesn’t call a filter , which is necessary to make Falang translate the excerpt.PARENT:
$excerpt = ! empty( $entry->post_excerpt ) ? $entry->post_excerpt : avia_backend_truncate( $entry->post_content, apply_filters( 'avf_magazine_excerpt_length', 60 ), apply_filters( 'avf_magazine_excerpt_delimiter', ' ' ), '…', true, '' );
CHILD ADAPTED:
$excerpt = ! empty( $entry->post_excerpt ) ? get_the_excerpt($entry->ID) : avia_backend_truncate( apply_filters('avf_magazine_entry_content',$entry->post_content,$entry), apply_filters( 'avf_magazine_excerpt_length', 60 ), apply_filters( 'avf_magazine_excerpt_delimiter', ' ' ), '…', true, '' );
So the change is from:
$entry->post_excerpt
to:
get_the_excerpt($entry->ID)
So question number 2:
As this could be needed by other translation plugins as well, could it be added to Enfold in a future update?Rob
- This reply was modified 4 years, 2 months ago by rob2701. Reason: fixed ellipsis in code
August 31, 2020 at 12:39 pm #1242157Hi,
For question number 2, any changes would need to be reviewed and tested by the dev team, so once the updated plugin is available we can submit this for review. As this could take some time I recommend adding this change via a child theme and the plugin could advise other Enfold users to do the same, for now.Best regards,
MikeAugust 31, 2020 at 12:51 pm #1242159Hi Mike,
Thanks for the good answers, very clear and helpful. I will keep you posted once the updated plugin is available.
Kind regards,
RobAugust 31, 2020 at 12:57 pm #1242161September 3, 2020 at 3:12 pm #1243122Hi,
Just for info:
Falang Multilanguage for WordPress 1.3.2 was just released, including many adaptations for use with Enfold.
RobSeptember 4, 2020 at 1:17 pm #1243305Hi rob2701,
Thank you for sharing!
Have a nice weekend! :)
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.