Home Forums Newsletter Plugin Support Newsletter with erros without configuration/code changes

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #64688

    Hello,
    I’m using your Automated Extension, in which I’ve created two channels: one for the portuguese newsletter (PT) and the other for the english version (EN). I’m using the qTranslate-X plugin to translate the contents. As such, I’ve created the following method to show the right text excerpt:

    function GetLanguage($startString="",$endString="",$str){
        $temp1 = strpos($str,$startString);
        if ($temp1 !== false) {
    		$temp1 = $temp1 + strlen($startString);
    		$result = substr($str,$temp1,strlen($str));
    		$dd=strpos($result,$endString);
        if($dd == 0){
            $dd = strlen($result);
        }
    		return substr($result,0,$dd);
    	}else{
    		return $str;
    	}
    }

    Example:
    $text = “[:pt]Olá mundo[:en]Hello world[:]”;

    GetLanguage(“[:en]”,”[:]”,$text); //Hello world
    GetLanguage(“[:pt]”,”[:en]”,$text); //Olá mundo

    So, the differences from the PT newsletter theme to the EN theme are:

    English theme.php

    <?php
    
    function GetLanguage($startString="",$endString="",$str){
        $temp1 = strpos($str,$startString);
        if ($temp1 !== false) {
    		$temp1 = $temp1 + strlen($startString);
    		$result = substr($str,$temp1,strlen($str));
    		$dd=strpos($result,$endString);
        if($dd == 0){
            $dd = strlen($result);
        }
    		return substr($result,0,$dd);
    	}else{
    		return $str;
    	}
    }
    (…)
    <?php foreach ($new_posts as $post) { ?>
    
                                <tr>
                                    <td>
                                        <br>
                                        <a href="<?php echo $post->link ?>"><img src="<?php echo $post->images['large'] ?>" style="max-width: 100%"></a> 
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <a style="font-family: <?php echo $post_title_font_family ?>; font-weight: bold; text-decoration: none; font-size: <?php echo $post_title_font_size ?>; color: <?php echo $post_title_color ?>" href="<?php echo $post->link ?>"><?php echo GetLanguage("[:en]","[:]",$post->title) ?></a>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="border-bottom: 1px solid #ccc">
                                        <a href="<?php echo $post->link ?>" style="text-decoration: none; font-size: 14px; color: #000000; display: block; line-height: 1.5em">
    										<?php echo GetLanguage("[:en]","[:]",$post->excerpt) ?>
                                        </a>
                                        <br>
                                        <?php if (!empty($read_more_label)) { ?>
                                            <div align="right">
                                                <a href="<?php echo $post->link ?>" style="text-decoration: none; font-size: 13px; color: #3570ba; display: inline-block; padding: 10px; background-color: white; border:2px solid #3570ba;text-transform: uppercase;font-weight: bold;">
                                                    <?php echo $read_more_label ?>
                                                </a>
                                            </div>
                                        <?php } ?>

    Portuguese theme.php

    <?php
    
    function GetLanguage($startString="",$endString="",$str){
        $temp1 = strpos($str,$startString);
        if ($temp1 !== false) {
    		$temp1 = $temp1 + strlen($startString);
    		$result = substr($str,$temp1,strlen($str));
    		$dd=strpos($result,$endString);
        if($dd == 0){
            $dd = strlen($result);
        }
    		return substr($result,0,$dd);
    	}else{
    		return $str;
    	}
    }
    (…)
    
    <?php foreach ($new_posts as $post) { ?>
    
                                <tr>
                                    <td>
                                        <br>
                                        <a href="<?php echo $post->link ?>"><img src="<?php echo $post->images['large'] ?>" style="max-width: 100%"></a> 
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <a style="font-family: <?php echo $post_title_font_family ?>; font-weight: bold; text-decoration: none; font-size: <?php echo $post_title_font_size ?>; color: <?php echo $post_title_color ?>" href="<?php echo $post->link ?>"><?php echo GetLanguage("[:pt]","[:en]",$post->title) ?></a>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="border-bottom: 1px solid #ccc">
                                        <a href="<?php echo $post->link ?>" style="text-decoration: none; font-size: 14px; color: #000000; display: block; line-height: 1.5em">
    										<?php echo GetLanguage("[:pt]","[:en]",$post->excerpt) ?>
                                        </a>
                                        <br>
                                        <?php if (!empty($read_more_label)) { ?>
                                            <div align="right">
                                                <a href="<?php echo $post->link ?>" style="text-decoration: none; font-size: 13px; color: #3570ba; display: inline-block; padding: 10px; background-color: white; border:2px solid #3570ba;text-transform: uppercase;font-weight: bold;">
                                                    <?php echo $read_more_label ?>
                                                </a>
                                            </div>
                                        <?php } ?>

    The problem is: sometimes the previews and the respective newsletter in the English channel are with the texts in PT, which does not make much sense because the themes are assigned correctly and this doesn’t always happen. There are times when everything is ok in the preview and I receive the newsletter correctly. In other times, the text (title and excepert) appear in portuguese in the previews and, consequently, the English newsletter (without configuration changes).

    https://ibb.co/imKAU6
    Channels

    https://ibb.co/eRTR2R
    https://ibb.co/exEoGm
    English Newsletter Channel

    https://ibb.co/cnqjp6
    English Newsletter (correct version)

    https://ibb.co/hKOR2R
    English Newsletter (with errors – title and excerpt text are in portuguese)

    I don’t understand why is it hapenning. Please help me because the site is already in production.
    Thank you.

    #65835
    Stefano
    Keymaster

    I think you should force the language forcing QT to se internally a language and then use the common template functions to extract the posts parts.

    Check with them how to force a language.

    The language could be an option of your custom theme.

    Stefano.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.