Jump to content


Wrapper not working for me


  • You cannot reply to this topic
3 replies to this topic

#1 elsinga

    Etomite Forum Newbie

  • Member
  • 43 posts

Posted 03 November 2004 - 06:21 AM

I am new to Etomite and using the latest 0.6 version. I added the Wrapper snippet with the following settings:

Snippet name:
Wrapper

Snippet code (just copy&pasted yesterday from etomite's snippet library):
# With most gratitude to Jason Murphy (Jason407) for making the Mambo original;)
#
# Wrapper - Etomite v0.6
#
# Adapted for Etomite by: John Maats - john-at-pn.nl 
# 
# Usage: 
#    Set defaults and use [ [Wrapper] ] inside your content 
#
# or call it with variables (example): 
#    [ [wrapper?wurl=http://etomite.com&wname=Etomite] ]
#
# Variable list:
#  $wurl      = "http://etomite.com";  // What would you like to show?
#  $wname     = "<b>Etomite</b>";          // Name to show
#  $wshowname = "1";                       // show the name? 1 yes, 0 no
#  $wwidth    = "100%";                    // width , recommended 100%
#  $wheight   = "600";                     // height, recommended 600 
#  $wscroll   = "auto";                    // auto, yes or no scrollbars visible
#  $wauto     = "1";                       // auto resize 1 yes, 0 no
#  $wframe    = "1";                       // show 1, hide 0 iframe borders
#  $wlink     = "1";                       // show direct link 1 yes, 0 no
#  $wwtext    = "Click here";              // Text for direct link
#
# If variable is not set, snippet will choose following defaults 

// your defaults, oh Master!
$durl      = "http://etomite.com";
$dname     = "<b>Etomite</b>";
$dshowname = "1";
$dwidth    = "100%";
$dheight   = "600";
$dscroll   = "auto";
$dauto     = "1";
$dframe    = "1";
$dlink     = "1";
$dwtext    = "Click here to open in new window!";

// No need to change stuff underneath...
// set defaults...
$wrapped ="";
if (!isset($wurl)) {$wurl = $durl; }
if (!isset($wheight)) {$wheight = $dheight; }
if (!isset($wwidth)) {$wwidth = $dwidth; }
if (!isset($wscroll)) {$wscroll = $dscroll; }
if (!isset($wframe)) {$wframe = $dframe; }
if (!isset($wname)) {$wname = $dname; }
if (!isset($wshowname)) {$wshowname = $dshowname; }
if (!isset($wlink)) {$wlink = $dlink; }
if (!isset($wwtext)) {$wwtext = $dwtext; }
// check for http:// in url
if (!(eregi("http://", $wurl) || (eregi("https://",$wurl)))) {
	$wurl = "http://".$wurl;
}
// need resize?
if ($wauto == "1"){
    $xload = "iFrameHeight()";
    $wrapped .= "<script language="JavaScript">";
    $wrapped .= "function iFrameHeight() {";
    $wrapped .= "  var h = 0;";
    $wrapped .= "  if(document.getElementById && !(document.all))";
    $wrapped .= "  {";
    $wrapped .= "    h = document.getElementById('blockrandom').contentDocument.height;";
    $wrapped .= "    document.getElementById('blockrandom').style.height = h + 60 + 'px';";
    $wrapped .= "  }";
    $wrapped .= "  else if(document.all)";
    $wrapped .= "  {";
    $wrapped .= "    h = document.frames('blockrandom').document.body.scrollHeight;";
    $wrapped .= "    document.all.blockrandom.style.height = h + 20 + 'px';";
    $wrapped .= "  }";
    $wrapped .= "}";
    $wrapped .= "</script>";
} else {
    $xload = "";
}
$wrapped .= "<script language="JavaScript">";
$wrapped .= "function blockError(){return true;}";
$wrapped .= "window.onerror = blockError;";
$wrapped .= "</script>";
$wrapped .= "<IFRAME id="blockrandom"";
$wrapped .= "onLoad="".$xload.""";
$wrapped .= "SRC="".$wurl.""";
$wrapped .= "width="".$wwidth."" height="".$wheight."" align=top scrolling=".$wscroll." frameborder=".$wframe.">Sorry, your Browser does NOT SUPPORT IFRAME.<br>You may want to Upgrade your Browser.<br><a href="".$wurl."" target="_blank">Click Here to see the page that was supposed to load.</a>".$wurl."</IFRAME>";
$wrapped .= "<div align="center">";

// need to show name?
if ($wshowname == "1") {
	$wrapped .= $wname;
}
$wrapped .= "<br>";
// need to show link?
if ($wlink == "1") {
	$wrapped .= "<a href="".$wurl."" target="_blank">[".$wwtext."]</a></div>";
}
return $wrapped;

I created a page inside the Etomite site, with the following settings:
Title:  Webalbum 
Long title:  the family Elsinga webalbum 
Description:  Galley of photo's 
Type:  Document 
Document's alias:  webalbum 
Keywords:  (Not set) 
  
Changes 
Created:  02/11/04 23:45:59 (elsinga) 
Edited:  03/11/04 07:13:58 (elsinga) 
  
Status 
Status:  Published 
Publish date:  (Not set) 
Un-publish date:  (Not set) 
Cacheable:  No 
Searchable:  No 
Menu index:  5 
  
Markup/ structure 
Uses template:  AlexisPro Redux 
Edit using rich text editor:  No 
Document is folder:  No

The document itself contains:
[[Wrapper?wurl=http://webalbum.elsinga.net]]

Now I get an error on the page and no wealbum showing:

Quote

Parse error: parse error, unexpected T_STRING in /home/elsinga/public_html/portal/index.php(556) : eval()'d code on line 58

What is going wrong here?

#2 jaredc

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,193 posts

Posted 03 November 2004 - 01:09 PM

The key is in the error message. Line 58 reads:

$wrapped .= "<script language="JavaScript">";
That will give you an error every time. The double quotes around the Javascript are not escaped. So PHP *thinks* that the string is "<script language=" (from the first quote to the second) and when it hits JavaScript, it doesn't know what to do because the string is over. Try this instead:

$wrapped .= '<script language="JavaScript">';
All I did here was change the double quotes around the whole thing to single quotes, leaving the doubles around JavaScript in tact. You could also have done:

$wrapped .= "<script language=\"JavaScript\">";
The slashes *escape* the quote right after telling PHP to count it as another character, NOT the start or end of a string. But that's not as easy to read. Matter of preference.

#3 pcwacht

    Etomite Forum Fan

  • Member
  • Pip
  • 135 posts

Posted 03 November 2004 - 03:32 PM

This was addressed earlier in this topic : http://www.etomite.com/index.php?showtopic=876&hl=

#4 elsinga

    Etomite Forum Newbie

  • Member
  • 43 posts

Posted 03 November 2004 - 03:51 PM

Thank you! Using the code from your site it now works. :D

Maybe this should also be edited in the snippet download section?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users