ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

error message {content} tag and replacing

September 14, 2010 3:37pm

Subscribe [5]
  • #1 / Sep 14, 2010 3:37pm

    phoebe_reed

    82 posts

    Hi,
    I need to do some parsing, translating, on the {content} tag of the error messages on our EE site.

    We have built a tri lingual site, and everything works great except for the redirect/error messages!  There seems to be no way to have them translate based on the global variable that holds the “country_code” information.

    I am very close, but don’t understand something about EE, please help.
    I have downloaded the system_messages plugin, so that we could work in a real template instead of the admin site.

    This is my content code on the template:

    {exp:replace_plus find="You did not submit a search term" replace="french version of you did not submitted a search term"}
    {content}
    {/exp:replace_plus}

    This doesn’t work at all. 

    However, the find/replace works if I use a string instead of the {content} tag.
    And the Content tag is working fine, it shows up, it just doesn’t get translated.

    We’ve been trying to solve this for about 2 weeks.  Please help.  We have to find a solution, or will have to… rebuild the entire site…?  There must be a way to do this.  I have tried about 8 solutions to no avail yet!

    Thanks for any help,
    Phoebe

  • #2 / Sep 15, 2010 3:19am

    John Henry Donovan

    12339 posts

    Phoebe,

    This thread is more appropriate in the CodeShare Corner so moving it here.

    Did you try a parse=“inward” on your plugin tag?

    {exp:replace_plus find="You did not submit a search term" replace="french version of you did not submitted a search term" parse="inward"}
    {content}
    {/exp:replace_plus}
  • #3 / Sep 15, 2010 12:20pm

    phoebe_reed

    82 posts

    Hm, inward tag doesn’t help. 

    I thought perhaps I could use includes, but I can’t get conditionals to work on the {content} tag either.. .must be the order of parsing….

    hmmm!

  • #4 / Sep 15, 2010 12:44pm

    phoebe_reed

    82 posts

    also just tried to affect the content of the {content} tag w/ php to no avail!

    <?php
    $content_v = "{embed:content}"; 
    $content_v =  str_replace  ("did not", "did", $content_v);
    echo $his; 
    ?>

    Returns, on the error template
    “You did not submit a search term”

    However,

    <?php
    $content_v = "You did not submit a search term"; 
    $content_v =  str_replace  ("did not", "did", $content_v);
    echo $his; 
    ?>

    Returns
    “You did submit a search term”

    So frustrating, because the php is working, the embed is working the the {content} is working, they just will NOT work together…..

    any suggestions?????

  • #5 / Oct 06, 2010 6:23pm

    Garrett

    36 posts

    Bump. I’m having the same issue.

  • #6 / Oct 06, 2010 8:25pm

    the3mus1can

    426 posts

    Is PHP set to input or output?

    Also:

    $content_v = "{embed:content}"; 
    $content_v =  str_replace  ("did not", "did", $content_v);
    echo $his;  //<---Where does $his get set?  Should it be $content_v?
  • #7 / Oct 06, 2010 8:45pm

    Garrett

    36 posts

    PHP is set to output. I’ve actually tried it on both just for fun. It seems the that {content} tag isn’t getting populated until AFTER everything else, including PHP.

    My setup is slightly different than Phoebe’s. Like her, I am using the Custom System Messages extension, but I am attempting to use PHP to parse the contents of {content} before it is outputted. To illustrate:

    <?php
    
    $message = "{content}";
    
    mail([all_appropriate_fields], $message);
    
    ?>

    I just used the mail function so I could see what exactly PHP was getting as the body of {content}. The mail message only contains:

    {content}

    so it’s obviously not getting set until AFTER PHP is evaluated.

  • #8 / Oct 06, 2010 10:00pm

    the3mus1can

    426 posts

    This is an issue with the Custom System Messages Extension.  The {content} and a few other tags are not parsed until after $this->EE->TMPL->run_template_engine($template[0], $template[1]); 

    Possible fix (add the following):

    $this->EE->config->_global_vars = array_merge($this->EE->config->_global_vars, $data);

    before line 157

    $this->EE->TMPL->run_template_engine($template[0], $template[1]);

    in the ext.system_messages.php file.  Warning this is untested.

  • #9 / Oct 07, 2010 1:48am

    Brian Litzinger

    711 posts

    the3mus1can, that is a good solution, I’ll look into adding that. I can add that, but I will probably prefix it with something like {csm:content} since {content} is a pretty generic variable name. That way if, just like in this case, {content} isn’t working, they can resort to using {csm:content}.

    Thanks for pointing this out.

  • #10 / Oct 07, 2010 1:51am

    Brian Litzinger

    711 posts

    This is untested too, but you can try this:

    foreach($data as $var => $value)
            {
                $this->EE->config->_global_vars['csm:'.$var] = $value;
            }
            
            // Parse the template
            $this->EE->TMPL->run_template_engine($template[0], $template[1]);

    Then you have {csm:content}, {csm:referrer} etc

    Let me know if that works for you.

  • #11 / Oct 07, 2010 12:35pm

    Garrett

    36 posts

    I tried Brian’s fix posted above and it appears to be working! PHP now has access to {csm:content}. Thank you very much gentlemen!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases