Programming + Design

Hacking the "Top Message" box in X-Cart PDF Print E-mail
Written by Brett Brewer   
Tuesday, 25 March 2008

Sometimes in developing various mods or hacks for x-cart, you may want to display a message to the user on the next page load after taking some action. To do this, x-cart supplies the $top_message session variable which is automatically registered on every page load and made available in your scripts. The $top_message variable is an array with a few flags you can set to control how the message displays.

$top_message['content'] .= "My warning";

$top_message['type'] = "W"; 

You can set the flag to "I" for info, "E" for errors, and "W" for warnings. The top message box will be styled accordingly. 

Also, if your script doesn't already assign the top message to a smarty template variable, you'll want to assign it before displaying your template:


Sometimes you may notice that your messages don't show up no matter what you try. Usually this is due to a page redirect happening in the background which clears the $top_message before you can display it. To get around this, put the following snippet in your script to keep the $top_message from being cleared on the next page load:

$adaptives['is_first_start'] = 'Y' ;    

Usually that will do the trick.  

Last Updated ( Tuesday, 25 March 2008 )
< Prev


Who's Online

We have 1 guest online

© 2017
Joomla! is Free Software released under the GNU/GPL License.