Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Modifying Pausing up-down scroller

  1. #1
    Join Date
    Aug 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Modifying Pausing up-down scroller

    Script Title: Pausing Up-Down Scroller

    Script URL (on DD): http://www.dynamicdrive.com/dynamicindex2/crosstick.htm

    Hi!

    I want to be able to use this pretty script on a website powered by website baker, but can't seem to get it to work. The CMS has a function
    Code:
    <?php page_content(x)?>
    where x stands for the number of content block you want to show. This command returns the page in html. When replacing the original "News content"
    Code:
    var pausecontent=new Array()
    pausecontent[0]='<a href="http://www.javascriptkit.com">JavaScript Kit</a><br />Comprehensive JavaScript tutorials and over 400+ free scripts!'
    with the
    Code:
    <?php show_pagecontent(x) ?>
    as follows
    Code:
    var pausecontent=new Array()
    pausecontent[0]='<?php show_pagecontent(x) ?>'
    , where "X" stands for the content block (i.e 2) I want to show, the scroller disapears from my site. When I'm viewing the source generated, everything looks OK (the text in pausecontent[0] seems just fine, with the same formatting as the example text.)

    Any ideas?

    Regards Vidar

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This may not be the problem but, could well be:

    First a mini lesson in delimiters. In this script's code the apostrophe is used to delimit (red) the string variables that make up the array:

    Code:
    pausecontent[0]='<a href="http://www.javascriptkit.com">JavaScript Kit</a><br />Comprehensive JavaScript tutorials and over 400+ free scripts!'
    and:

    Code:
    pausecontent[0]='<?php show_pagecontent(x) ?>'

    If you have an apostrophe in the variable string (green), it must be escaped with the down slash (\):

    Code:
    pausecontent[0]='That\'s Right'
    If the server side string represented by:

    PHP Code:
    <?php show_pagecontent(x?>
    contains one or more apostrophes, They each must be escaped in the same manner in the source for that string.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi John!

    Thank you for your reply!
    I've checked the string returned by the php script (using view source), and it does not contain any apostrophes. Even if I try to return the same string as in the original code, the script does not show. (But viewing the code, everything looks 100% like the example code).

    Vidar

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Perhaps a link to your problem page or a demo of the problem would help me figure it out. It may not as, PHP does obscure some things from a view source but, usually enough information is present to make a determination.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Aug 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi!

    I've set up a demo on http://test.hallais.no

    Edit: Writing a post without <br /> tag works just fine!? Why? There are <br /> tags in the default content, and this works fine?
    Does the string variable have to be declared in one line?


    Regards Vidar
    Last edited by vidi; 08-27-2006 at 07:07 PM.

  6. #6
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Newlines strike again.
    Change
    PHP Code:
    <?php show_pagecontent(x?>
    to
    PHP Code:
    <?php
    ob_start
    ();
    show_pagecontent(x)
    $output ob_get_contents();
    ob_end_clean();
    $output str_replace("\n"""$output);
    $output str_replace("\r"""$output);
    echo 
    $output;
    ?>

  7. #7
    Join Date
    Aug 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi blm126!
    When replacing
    Code:
     <?php show_pagecontent(x) ?>
    with
    Code:
    <?php
    ob_start();
    show_pagecontent(x)
    $output = ob_get_contents();
    ob_end_clean();
    $output = str_replace("\n", "", $output);
    $output = str_replace("\r", "", $output);
    echo $output;
    ?>
    the whole page disapear (blank page, nothing parsed)... The beginning of the script then looks like this
    Code:
    <script type="text/javascript">
    
    /*Example message arrays for the two demo scrollers*/
    
    var pausecontent=new Array()
    pausecontent[0]='<?php
    ob_start();
    show_pagecontent(x)
    $output = ob_get_contents();
    ob_end_clean();
    $output = str_replace("\n", "", $output);
    $output = str_replace("\r", "", $output);
    echo $output;
    ?> '
    pausecontent[1]='<a href="http://www.codingforums.com">Coding Forums</a><br />Web coding and development forums.'
    pausecontent[2]='<a href="http://www.cssdrive.com" target="_new">CSS Drive</a><br />Categorized CSS gallery and examples.'
    Regards Vidar

  8. #8
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    My bad, I forgot a semi colon. Try this
    Code:
    <?php
    ob_start();
    show_pagecontent(x);
    $output = ob_get_contents();
    ob_end_clean();
    $output = str_replace("\n", "", $output);
    $output = str_replace("\r", "", $output);
    echo $output;
    ?>

  9. #9
    Join Date
    Aug 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I've tried that, still problems. When opening the page, only the background images and colors are displayed. Viewing the source gives me this:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <link href="http://test.hallais.no/templates/hatex_fremside/screen.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="http://test.hallais.no/templates/hatex_fremside/print.css" rel="stylesheet" type="text/css" media="print" />
    <style type="text/css">
    <!--
    @import url("screen.css");
    -->
    </style>
    <style type="text/css">
    
    /*Example CSS for the two demo scrollers*/
    
    #pscroller1{
    width: 200px;
    height: 100px;
    border: 1px solid black;
    padding: 5px;
    background-color: lightyellow;
    }
    
    #pscroller2{
    width: 350px;
    height: 20px;
    border: 1px solid black;
    padding: 3px;
    }
    
    #pscroller2 a{
    text-decoration: none;
    }
    
    .someclass{ //class to apply to your scroller(s) if desired
    }
    
    </style>
    
    
    <script language="JavaScript">
    <!--
    
    function SymError()
    {
      return true;
    }
    
    window.onerror = SymError;
    
    var SymRealWinOpen = window.open;
    
    function SymWinOpen(url, name, attributes)
    {
      return (new Object());
    }
    
    window.open = SymWinOpen;
    
    //-->
    </script>
    
    <script type="text/javascript">
    
    /*Example message arrays for the two demo scrollers*/
    
    var pausecontent=new Array()
    pausecontent[0]='
    <script language="JavaScript">
    <!--
    var SymRealOnLoad;
    var SymRealOnUnload;
    
    function SymOnUnload()
    {
      window.open = SymWinOpen;
      if(SymRealOnUnload != null)
         SymRealOnUnload();
    }
    
    function SymOnLoad()
    {
      if(SymRealOnLoad != null)
         SymRealOnLoad();
      window.open = SymRealWinOpen;
      SymRealOnUnload = window.onunload;
      window.onunload = SymOnUnload;
    }
    
    SymRealOnLoad = window.onload;
    window.onload = SymOnLoad;
    
    //-->
    </script>
    As you can see, the script is "cut of" where the red letters are...

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by vidi
    viewing the code, everything looks 100% like the example code
    Not at: http://test.hallais.no/

    This (from above link's source):

    Code:
    <script type="text/javascript">
    
    /*Example message arrays for the two demo scrollers*/
    
    <script type="text/javascript">var pausecontent=new Array()pausecontent[]='<a href='http://test.hallais.no/pages//posts/flere-nyheter3.php">Flere nyheter</a><br />njcldsvhdjskavhsdgjakVC.GHJASK.'pausecontent[]='<a href='http://test.hallais.no/pages//posts/test-nyhet2.php">Test nyhet</a><br />Javell! Dette e ein liden testnyhet, for &aring; se kordan det virke.'pausecontent[]='<a href='http://test.hallais.no/pages/.php"></a><br />'</script>
    Should be like this:

    Code:
    <script type="text/javascript">
    var pausecontent=new Array();
    pausecontent[0]='<a href="http://test.hallais.no/pages//posts/flere-nyheter3.php">Flere nyheter</a><br />njcldsvhdjskavhsdgjakVC.GHJASK.';
    pausecontent[1]='<a href="http://test.hallais.no/pages//posts/test-nyhet2.php">Test nyhet</a><br />Javell! Dette e ein liden testnyhet, for &aring; se kordan det virke.';
    pausecontent[2]='<a href="http://test.hallais.no/pages/.php"></a><br />';
    </script>
    And, in the quoted source, there are apostrophes (red) inside the delimiters, ex:

    Code:
    pausecontent[]='<a href='http://te . . .
    That one, rather than being escaped, as I mentioned before, should just be changed to a quote("). Notice also the missing number from the square brackets (green).
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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