Zen Cart Logo
Forums / Basic Configuration / Putting code into Kuroi's Blank Sidebox

Putting code into Kuroi's Blank Sidebox

Locked

Views: 3,137

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
18 Mar 2008, 3:07 AM
#1
dealbyethan_com avatar

dealbyethan_com

Totally Zenned

Join Date:
Dec 2005
Location:
Perth, Western Australia, Australia
Posts:
782
Plugin Contributions:
0

Putting code into Kuroi's Blank Sidebox

Hi,

I am trying to get the following code to integrate and work properly in Kuroi's Blank Sidebox.

<script language="Javascript" type="text/javascript">

var fieldstocheck = new Array();
    fieldnames = new Array();

function checkform() {
  for (i=0;i<fieldstocheck.length;i++) {
    if (eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].value") == "") {
      alert("Please enter your "+fieldnames[i]);
      eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].focus()");
      return false;
    }
  }

  return true;
}


function addFieldToCheck(value,name) {
  fieldstocheck[fieldstocheck.length] = value;
  fieldnames[fieldnames.length] = name;
}

function compareEmail()
{
  return (document.subscribeform.elements["email"].value == document.subscribeform.elements["emailconfirm"].value);
}

</script><form method=post action="http://www.dealbyethan.com/newsletters/?p=subscribe&id=1" name="subscribeform" target="windowName" onsubmit="window.open('', this.target,
'dialog,modal,scrollbars=no,resizable=no,width=550,height=300,left=0,top=0');"><style type="text/css">
      div.adminmessage {
        width: 100%;
        border: 2px dashed #000000;
        padding: 10px;
        margin-bottom: 15px;
        background-color: #E7BE8F;

      }
      </style>

Email: <input type=text name=email value="" size="15">
  <script language="Javascript" type="text/javascript">addFieldToCheck("email","Email");</script>
        
        <input type="hidden" name="list[3]" value="signup"><input type="hidden" name="listname[3]" value="Mens Clothing"/><input type=submit name="subscribe" value="Subscribe" onClick="return checkform();">
    </form>

It's essentially a simple phplist subscription with a field and subcribe button. I put the code in tpl_blank_sidebox.php but it gave me this error. The above code works fine if it wasn't in a sidebox. Please advise. Thank you.

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING

18 Mar 2008, 4:05 AM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,611
Plugin Contributions:
0

Re: Putting code into Kuroi's Blank Sidebox

http://www.faqts.com/knowledge_base/view.phtml/aid/7731 - google is a wonderful thing :smile:

18 Mar 2008, 4:12 AM
#3
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Putting code into Kuroi's Blank Sidebox

Why reinvent the wheel?

In the Downloads section you can get the Newsletter Sign up Module which sounds better for what you want.

18 Mar 2008, 5:51 AM
#4
dealbyethan_com avatar

dealbyethan_com

Totally Zenned

Join Date:
Dec 2005
Location:
Perth, Western Australia, Australia
Posts:
782
Plugin Contributions:
0

Re: Putting code into Kuroi's Blank Sidebox

@Kim: Thanks for the link. I will check and report back.

@Website Rob: Yes, I am using that. It works well but when it comes to sending newsletters it come across a problem.

I can't send newsletters in bulk to over 800 customers in zencart admin. It gave me a blank page and I know some customers received my newsletter but not others. So I thought of using the Newsletter Subscription Module in conjuction with phplist. This means I can make customers subscribe on zencart and then unsubscribe on zencart only OR phplist only. Although I am okay with exporting the email addresses from zencart admin and import them into phplist, these two methods are not good because if someone uses the former method, they will not be automatically be unsubscribed on phplist and vice versa for the latter method.

I am thinking to switch to use phplist entirely because it can do subscription, unsubscription and newsletters reliably. Hence I thought of an idea to display a simple phplist subscription with an email field and subscribe button in a blank sidebox. I hope this make sense.

You might say there is also a phplist module called Newsletter Center but it does not integrate well with zencart at this stage.

18 Mar 2008, 10:30 AM
#5
dealbyethan_com avatar

dealbyethan_com

Totally Zenned

Join Date:
Dec 2005
Location:
Perth, Western Australia, Australia
Posts:
782
Plugin Contributions:
0

Re: Putting code into Kuroi's Blank Sidebox

@Kim: I took your suggestion... checked through the code and then tried again with no luck. The same error message shows up. Can anyone please help? Thanks.

18 Mar 2008, 10:32 AM
#6
dealbyethan_com avatar

dealbyethan_com

Totally Zenned

Join Date:
Dec 2005
Location:
Perth, Western Australia, Australia
Posts:
782
Plugin Contributions:
0

Re: Putting code into Kuroi's Blank Sidebox

The following shows what I tried:

<?php
/**
 * blank sidebox - allows a blank sidebox to be added to your site
 *
 * @package templateSystem
 * @copyright 2007 Kuroi Web Design
  * @copyright Portions Copyright 2003-2007 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: blank_sidebox.php 2007-05-26 kuroi $
 */

  $content = '';
  $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';

  // Replace the text and HTML tags between the apostophes on lines 19 and 20.
  // Use as many or as few lines using this model as you need for your custom content.
  // If you have a multilingual site define your text in the languages/YOUR_LANGUAGE/extra_definitions/blank_sidebox_defines.php and include it as shown in line 19.
  // If your site is monolingual, you can put the text right here as shown on line 20 (and nobody will know!)
  $content .= '<p>' . TEXT_BLANK_SIDEBOX . '</p>';
  $content .= '<script language="Javascript" type="text/javascript">

var fieldstocheck = new Array();
    fieldnames = new Array();

function checkform() {
  for (i=0;i<fieldstocheck.length;i++) {
    if (eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].value") == "") {
      alert("Please enter your "+fieldnames[i]);
      eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].focus()");
      return false;
    }
  }

  return true;
}


function addFieldToCheck(value,name) {
  fieldstocheck[fieldstocheck.length] = value;
  fieldnames[fieldnames.length] = name;
}

function compareEmail()
{
  return (document.subscribeform.elements["email"].value == document.subscribeform.elements["emailconfirm"].value);
}

</script><form method=post action="http://www.dealbyethan.com/newsletters/?p=subscribe" name="subscribeform"><style type="text/css">
      div.adminmessage {
        width: 100%;
        border: 2px dashed #000000;
        padding: 10px;
        margin-bottom: 15px;
        background-color: #E7BE8F;

      }
      </style>

Email:
<input type=text name=email value="" size="15">
<script language="Javascript" type="text/javascript">addFieldToCheck("email","Email");</script>

<input type="hidden" name="list[3]" value="signup"><input type="hidden" name="listname[3]" value="Mens Clothing"/><input type=submit name="subscribe" value="Subscribe" onClick="return checkform();">
    </form>';

  $content .= '</div>';
?>
14 Jul 2008, 6:17 PM
#7
learning1 avatar

learning1

New Zenner

Join Date:
Jul 2008
Posts:
24
Plugin Contributions:
0

Re: Putting code into Kuroi's Blank Sidebox

I am a totally new Zenner..but liking what I have seen so far. I am trying to add an "Open in new Window" the the Blank Sidebox addon. The code is pretty simply :

<body> <script language="JavaScript" type="text/JavaScript"> <!-- function opennewWindow(theURL,winName,features) { window.open(theURL,winName,features); } //--> </script> <a href="javascript:opennewWindow('measure_kit.html','','scrollbars=yes, width=525')">How to Measure</a> </body>

I have created a file nemed jscript_measure.js and placed it in the includes/modules/pages/product_info folder so it would automatically load as I read in previous posts.

I have added lines below to the tpl_blank_sidebox.php file:

$content .= '<a href="javascript:opennewWindow('measure_kit.html','','scrollbars=yes, width=525')">How to Measure</a>';

The page does not totally load. I have removed the <a href.... line to see if the issue is there and it seems to be since the page will load fine...but no active link.

This code works fine in a HTML page I tested it in. Please tell me what I am missing.

14 Jul 2008, 10:28 PM
#8
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Putting code into Kuroi's Blank Sidebox

@learning1

The javascript that you are trying to insert should indeed work fine on an HTML page, but will break a PHP page. No surprises there, that's what you're seeing.

The reason is all those single quotes. PHP doesn't know that the new ones that you're inserting are meant for the javascript and not for it, and it's trying to process them.

To get around this you need to "escape" those which PHP should ignore by putting a "" in front of them. So your line becomes:

$content .= '<a href="javascript:opennewWindow(\'measure_kit.html\',\'\',\'scrollbars=yes, width=525\')">How to Measure</a>';

15 Jul 2008, 12:18 PM
#9
learning1 avatar

learning1

New Zenner

Join Date:
Jul 2008
Posts:
24
Plugin Contributions:
0

Re: Putting code into Kuroi's Blank Sidebox

Excellent - exactly what was wrong. I should have also mentioned that I am new to PHP/MySQL as well - my previous web work has all been .asp.

Thanks so much - I know it won't be my last question, but I thought I would post something since I was searching the forum for the past 2 days and couldn't find a soultion.