Posted on: 04/13/05 01:06am
By: Turner
I have created a phpblock function that tries to return the following javascript
$retval .= '<script>';
$retval .= "var scroll1 = new vScroll('scroll1','kigBoxDiv');";
$retval .= 'scroll1.setWidth("99%");';
$retval .= 'scroll1.setHeight("150px");';
$retval .= "scroll1.setContent('" . $display . "');";
$retval .= "scroll1.writeDiv('outerClass','innerClass');";
$retval .= '</script>';
The crazy thing is $retval is always blank -
UNLESS I remove the closing script tag. I can echo the contents of $retval after almost every line. But when I try to echo $retval after the last line, $retval is blank.
Does this make sense to anyone?
-Jeff
Does Geeklog strip scripts?!!
Posted on: 04/13/05 09:36am
By: Turner
If no one is able (willing?) to answer this, then perhaps someone might be willing to answer my next question.
Do you think my problem with this issue is Geeklog related or is it some quirk with javascript and browsers that disallows me the ability to return contents between script tags in PHP? I simply want to return a javascript script to a block! But it seems the script is actually being interpreted so that my return variable is blank.
Is there a way to return the script? This is the only thing standing between me and my javascript scroller within a block.
Please help!
Does Geeklog strip scripts?!!
Posted on: 04/13/05 10:43am
By: ScurvyDawg
OK
I am in no way an expert in javascript but I have used it a number of times. If I were to want to use a script in a block I would create a normal block.
I would put the javascript call in the normal block.
I would put the script itself where it belongs in the head of the website.
To put the script in the head of the GL you need to place it into the header.thtml.
Then it should just work.
?
Does Geeklog strip scripts?!!
Posted on: 04/13/05 11:22am
By: Turner
The content will not be static. It will scroll the titles of current stories from a certain topic. So, it seems to me I will need to use PHP to select the titles from TOPICS, accumulate the list in $retval, format the list for javascript as you see I am trying to do, and then return it to the block.
I am loading the actual javascript in the header. The code you see in this thread simply calls the script. If I don't enclose it in a script tag, it just prints out code in a block.
Funny thing is, if I just dump this stuff in a normal block (with static content), it scrolls just fine. So it seems to me I should be able to pass it from php into a block.
Thanks for your reply.
-Jeff
Does Geeklog strip scripts?!!
Posted on: 04/13/05 03:20pm
By: Dirk
FWIW, Geeklog doesn't do anything with the content returned from a PHP block. It will be added directly to the rest of the HTML to be displayed (sandwiched between a block header and footer). No filters are applied.
bye, Dirk
Does Geeklog strip scripts?!!
Posted on: 04/13/05 05:09pm
By: Turner
Okay! Well that tells me quite a lot, I think. It tells me that I have an error in the way I am setting up the javascript code. Likely, the browser cannot properly interpret the returned javascript and so $retval does not acquire a value.
Every little bit helps.
Thanks!
Does Geeklog strip scripts?!!
Posted on: 04/13/05 05:48pm
By: Turner
I see the problem in the code, but don't exactly know how to get around it. The content to be scrolled is causing the difficulty.
I am collecting the content in a variable called $display.
Then I pass $display to a javascript function like this:
$retval .= 'scroll1.setContent("$display");';
If the contents of $display has a quotation mark in it, then it serves as the terminating quotation mark for the function and therefore should be followed by a parenthesis.
Is there a way to get around this? Hopefully someone will see the quick solution and post it.
Does Geeklog strip scripts?!!
Posted on: 04/13/05 08:10pm
By: Turner
Well. addslashes() is the trick. I was just sitting at dinner thinking that some of the code I've seen sometimes has '/' in front of quotation marks. Now I know why.
Glad I'm over that. Have learned a lot. scroller still needs work. But at least we're past this.
-Jeff