Welcome to Geeklog, Anonymous Thursday, February 02 2023 @ 11:15 pm EST

Geeklog Forums

Does Geeklog strip scripts?!!


Status: offline

Turner

Forum User
Chatty
Registered: 04/11/05
Posts: 42
I have created a phpblock function that tries to return the following javascript

Text Formatted Code
        $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
 Quote

Status: offline

Turner

Forum User
Chatty
Registered: 04/11/05
Posts: 42
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! praying it will work Mr. Green Laughing
 Quote

Status: offline

ScurvyDawg

Forum User
Full Member
Registered: 11/06/02
Posts: 523
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.

?

Blah Blah Blah Blah ... Just my two cents
 Quote

Status: offline

Turner

Forum User
Chatty
Registered: 04/11/05
Posts: 42
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
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
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
 Quote

Status: offline

Turner

Forum User
Chatty
Registered: 04/11/05
Posts: 42
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!
 Quote

Status: offline

Turner

Forum User
Chatty
Registered: 04/11/05
Posts: 42
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.
 Quote

Status: offline

Turner

Forum User
Chatty
Registered: 04/11/05
Posts: 42
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
 Quote

All times are EST. The time is now 11:15 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content