Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Join Date
    Jul 2008
    Posts
    11
    Plugin Contributions
    0

    Default How can I put attribute errors into a javascript popup?

    Hi

    I would like all errors to display in a javascript popup rather than in a yellow box on the page.

    The create_account page does this by default by showing a popup like this:


    but in the product_info page it displays this ugly yellow box like this:


    does anyone have an idea how to do this?

  2. #2
    Join Date
    Jul 2008
    Posts
    11
    Plugin Contributions
    0

    Default messagestack

    Hi,

    does anyone know if it's possible to display messagestack messages in a javascript alert?

    for example if a customer adds a product to the cart but forgets to select a required attribute it is displayed on top of the product info page. but i'd like it to show up in a popup w/out reloading the page...

    for some reason zen-cart does this automatically if one would forget to enter required data on the create account page...

    any ideas?

  3. #3
    Join Date
    Sep 2007
    Location
    Dublin, Ireland
    Posts
    1,288
    Plugin Contributions
    8

    Default Re: messagestack

    Quote Originally Posted by rkarta View Post
    Hi,

    does anyone know if it's possible to display messagestack messages in a javascript alert?

    for example if a customer adds a product to the cart but forgets to select a required attribute it is displayed on top of the product info page. but i'd like it to show up in a popup w/out reloading the page...

    for some reason zen-cart does this automatically if one would forget to enter required data on the create account page...

    any ideas?
    It could be done. Problem is that it's not likely to be easy. The messagestack is PHP (server side) while alerts tend to be Javascript (client side).

    Hopefully it would just be a case of replacing the message stack display code with something like:

    PHP Code:
    echo '<script>alert("'.$message.'");</script>'
    Andrew

    Andrew Moore
    Omnicia Agile Development
    www.omnicia.com

  4. #4
    Join Date
    Jul 2008
    Posts
    11
    Plugin Contributions
    0

    Default Re: messagestack

    PHP Code:
    echo '<script>alert("'.$message.'");</script>'
    Hmmm this did not seem to work for me... but maybe it's my lack of knowledge...

    I tried adding it to tpl_message_stack_default.php and I got as far as the popup displaying ' .. ' but it won't show the message

    Do you have an idea how to merge it into this file (show below)

    PHP Code:
    <?php
    ?>
    <?php 
    for ($i=0$n=sizeof($output); $i<$n$i++) { ?>
      <div <?php echo $output[$i]['params']; ?>><?php echo $output[$i]['text']; ?></div>

    <?php ?>
    Your help is highly appreciated!

  5. #5
    Join Date
    Sep 2007
    Location
    Dublin, Ireland
    Posts
    1,288
    Plugin Contributions
    8

    Default Re: messagestack

    Quote Originally Posted by rkarta View Post
    PHP Code:
    echo '<script>alert("'.$message.'");</script>'
    Hmmm this did not seem to work for me... but maybe it's my lack of knowledge...

    I tried adding it to tpl_message_stack_default.php and I got as far as the popup displaying ' .. ' but it won't show the message

    Do you have an idea how to merge it into this file (show below)

    PHP Code:
    <?php
    ?>
    <?php 
    for ($i=0$n=sizeof($output); $i<$n$i++) { ?>
      <div <?php echo $output[$i]['params']; ?>><?php echo $output[$i]['text']; ?></div>

    <?php ?>
    Your help is highly appreciated!
    Sorry '$message' in my previous message was just pseudo-code. Try this:

    PHP Code:
    $message="";
    foreach(
    $output as $thisoutput)
     
    $message.=$thisoutput['text'].'\n';

    echo 
    '<script>alert("'.$message.'");</script>'
    Andrew

    Andrew Moore
    Omnicia Agile Development
    www.omnicia.com

  6. #6
    Join Date
    Jul 2008
    Posts
    11
    Plugin Contributions
    0

    Default Re: messagestack

    Hmm this didn't work either. The popup message just doesn't show up. I think the problem is in the message. If I echo $output it displays "Array". if I echo <?php echo $output[$i]['text']; ?> it displays this (copied from result source):

    PHP Code:
    <div class="messageStackCaution larger"><img src="includes/templates/template_default/images/icons/warning.gif" alt="Warning" title=" Warning ">  Please correct the following: <brOn the option  <span class="alertBlack">Color</spanplease <span class="alertBlack">...</span><brOn the option  <span class="alertBlack">Size</spanplease <span class="alertBlack">...</span><br>Array </div
    I think alert() can't handle this...

  7. #7
    Join Date
    Sep 2007
    Location
    Dublin, Ireland
    Posts
    1,288
    Plugin Contributions
    8

    Default Re: messagestack

    We can strip out the tags. Try this:

    PHP Code:
    $message="";
    foreach(
    $output as $thisoutput)
     
    $message.=strip_tags($thisoutput['text']).'\n';

    echo 
    '<script>alert("'.$message.'");</script>'
    Andrew

    Andrew Moore
    Omnicia Agile Development
    www.omnicia.com

  8. #8
    Join Date
    Jul 2008
    Posts
    11
    Plugin Contributions
    0

    Default Re: messagestack

    Sweet! it works! thanks a lot! it's so much nicer than the default messagestack. i've added the lightalert.js script to it and it looks way better

    just one thing: now the breaks are removed too so the text shows in one line like this:

    Please correct the following: On the option for size please select On the option for color please select

    rather than

    Please correct the following:
    On the option for size please select
    On the option for color please select

    do you know how to fix this???

  9. #9
    Join Date
    Sep 2007
    Location
    Dublin, Ireland
    Posts
    1,288
    Plugin Contributions
    8

    Default Re: messagestack

    Quote Originally Posted by rkarta View Post
    Sweet! it works! thanks a lot! it's so much nicer than the default messagestack. i've added the lightalert.js script to it and it looks way better

    just one thing: now the breaks are removed too so the text shows in one line like this:

    Please correct the following: On the option for size please select On the option for color please select

    rather than

    Please correct the following:
    On the option for size please select
    On the option for color please select

    do you know how to fix this???
    Strange- the part that says '\n' is a line break.
    Andrew

    Andrew Moore
    Omnicia Agile Development
    www.omnicia.com

  10. #10
    Join Date
    Jul 2008
    Posts
    11
    Plugin Contributions
    0

    Default Re: messagestack

    I changed $message.=strip_tags($thisoutput['text']).'\n';
    to $message=strip_tags($thisoutput['text'],'<br>');
    and now it works!

    for some reason the \n didn't work but now it's fine. I just have to change all \n to <br>.

    Thanks a lot for your help!!!!!!!!

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v151 How can I put an image into main page template?
    By Twitchin Kitten in forum Templates, Stylesheets, Page Layout
    Replies: 15
    Last Post: 7 Mar 2016, 11:00 PM
  2. v150 How to put Attribute Images into Columns?
    By beyre in forum Setting Up Categories, Products, Attributes
    Replies: 15
    Last Post: 26 Nov 2012, 08:10 PM
  3. Can I put a WYSIWYG Editor into a Text Box Attribute?
    By NCSWI in forum Setting Up Categories, Products, Attributes
    Replies: 5
    Last Post: 9 Aug 2011, 10:30 PM
  4. Can I put a "click for details" popup in my attribute descriptions?
    By brandonturpin in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 16 Oct 2009, 03:20 PM
  5. Shipping Estimator Popup - Javascript Errors in IE
    By thehin in forum General Questions
    Replies: 1
    Last Post: 12 Jul 2007, 05:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg