Advertisement:

Author Topic: flash messages not showing on twitter theme after upgrading to 3.3.2  (Read 1817 times)

bbcz2551

  • Newbie
  • *
  • Posts: 19
Gud Morning All I Have Just upgraded to Ver. 3.3.2 But flash messages not showing on twitter theme  ....Can anybody help me ASAP

Thanx N Regards

http://easydial.in
« Last Edit: February 28, 2014, 07:46:09 pm by bbcz2551 »

leonidasw

  • Newbie
  • *
  • Posts: 11
Re: flash messages not showing on twitter theme after upgrading to 3.3.2
« Reply #1 on: March 13, 2014, 04:27:18 am »
Hi bbcz2551

I was stucked in the same problem few days and I get a part of the solution !
I m not a php developper so any advice is welcome.

This is the solution I founded

You have to add this function in the file : \oc-includes\osclass\helpers\hMessages.php



Code: [Select]

function twitter_show_flash_message($section = 'pubMessages', $class = "flashmessage", $id = "flashmessage") {
        $messages = Session::newInstance()->_getMessage($section);
        if (is_array($messages)) {

            foreach ($messages as $message) {

                echo '<div id="flash_js"></div>';
       
                if (isset($message['msg']) && $message['msg'] != '') {
                    echo '<div class="alert-message ' . $message['type'] . '">' ;
                echo '<a class="close" href="#">×</a>';
                echo '<p>' . $message['msg'] . '</p>';
                echo '</div>' ;
                } else if($message!='') {
                    echo '<div id="' . $id . '" class="' . $class . '">';
                    echo osc_apply_filter('flash_message_text', $message);
                    echo '</div>';
                } else {
                    echo '<div id="' . $id . '" class="' . $class . '" style="display:none;">';
                    echo osc_apply_filter('flash_message_text', '');
                    echo '</div>';
                }
            }
        } 
        Session::newInstance()->_dropMessage($section);
    }



I tried to put the code directly in the root of my theme \oc-content\themes\twitter\function.php   but it doesnt work

Hope it helps !

ikrougovoi

  • Newbie
  • *
  • Posts: 15
Re: flash messages not showing on twitter theme after upgrading to 3.3.2
« Reply #2 on: March 16, 2014, 09:55:28 pm »
I got it working like this:

Went into every PHP form of the template and replaced:
Code: [Select]
<?php twitter_show_flash_message() ; ?>
with
Code: [Select]
<?php osc_show_flash_message() ; ?>
So what's happening now is that we are using the OS Class built in messaging system instead of the twitter theme's implementation.

Now we have to apply the CSS (because the OS Class' message CSS isn't something to write home about)

So go into your oc-includes\osclass\helpers\hMessages.php
and replace line 103 with this:
Code: [Select]
echo '<div id="' . $id . '" class="alert-message ' . strtolower($class) . ' ' . strtolower($class) . '-' .$message['type'] . '"><a class="close" href="#">×</a>';

Here we are just adding the Twitter classes to the messages so that it looks good.

The only disadvantage to this is that the error messages aren't that nice.
For instance: "Title too short (en_US). Email invalid."

ikrougovoi

  • Newbie
  • *
  • Posts: 15
Re: flash messages not showing on twitter theme after upgrading to 3.3.2
« Reply #3 on: March 18, 2014, 03:15:02 am »
My above post breaks some of the Admin pages alerts.

If you followed my post above then please revert all pages back to calling twitter_show_flash_message()
and revert the hMessage.php file back to the original

Here's the fully working fix:

Alright.. Final fix:
ensure all of your PHP pages are calling:
twitter_show_flash_message()

ensure your osc_show_flash_message function inside the helpers\hMessage.php file is the original (if you've changed it as per our discussion above)

now inside your theme\functions.php file look for the following lines (85 for Twitter, 86 for Repurpose)
Code: [Select]
    if( !function_exists('twitter_show_flash_message') ) {
        function twitter_show_flash_message() {
            $message = Session::newInstance()->_getMessage('pubMessages') ;

            if (isset($message['msg']) && $message['msg'] != '') {
                if( $message['type'] == 'ok' ) $message['type'] = 'success' ;
                echo '<div class="alert-message ' . $message['type'] . '">' ;
                echo '<a class="close" href="#">×</a>';
                echo '<p>' . $message['msg'] . '</p>';
                echo '</div>' ;

                Session::newInstance()->_dropMessage('pubMessages') ;
            }
        }
    }

and replace it with:
Code: [Select]
    if( !function_exists('twitter_show_flash_message') ) {
    function twitter_show_flash_message($section = 'pubMessages', $class = "alert-message", $id = "alert-message") {
        $messages = Session::newInstance()->_getMessage($section);
        if (is_array($messages)) {

            foreach ($messages as $message) {

                echo '<div id="flash_js"></div>';
       
                if (isset($message['msg']) && $message['msg'] != '') {
                    echo '<div id="' . $id . '" class="' . strtolower($class) . ' ' .$message['type'] . '"><a class="close">x</a>';
                    echo osc_apply_filter('flash_message_text', $message['msg']);
                    echo '</div>';
                } else if($message!='') {
                    echo '<div id="' . $id . '" class="' . $class . '">';
                    echo osc_apply_filter('flash_message_text', $message);
                    echo '</div>';
                } else {
                    echo '<div id="' . $id . '" class="' . $class . '" style="display:none;">';
                    echo osc_apply_filter('flash_message_text', '');
                    echo '</div>';
                }
            }
        } 
        Session::newInstance()->_dropMessage($section);
}
}

What we're doing here is essentially re-using the built in OS Class messaging function, but setting the class and close button for the alert to the Twitter CSS classes.
Now this is not best practice as we now have duplicate code in our application.. But hey it works!
I'm pretty sure the twitter one does NOT work because:
Code: [Select]
$message = Session::newInstance()->_getMessage('pubMessages') ;returns an Array, where as the twitter function is expecting ONE message....

Your Admin pages should all still be using osc_show_flash_messages which we have set back to the original one.
Now everything works :)