Results 1 to 9 of 9

Thread: Ajax Pagination script problem

  1. #1
    Join Date
    Aug 2008
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Thumbs up Ajax Pagination script problem

    Script: Ajax Pagination script v1.2
    http://dynamicdrive.com/dynamicindex...nate/index.htm



    Hello Dynamic Drive Team

    i want to use Ajax Pagination script v1.2 for my jamroom site.

    My problem is, jamroom works with smarty and so i cant use my vaiables in the script!

    PHP Code:
    <script type="text/javascript">

    var 
    bookonflowers={
    pages: ["demofiles/flower.htm""demofiles/flower2.htm""demofiles/flower3.htm""demofiles/flower4.htm"],
    selectedpage//set page shown by default (0=1st page)
    }

    var 
    mybookinstance=new ajaxpageclass.createBook(bookonflowers"bookcontent", ["paginate-top""paginate-bottom"])

    </script> 

    At these place:
    PHP Code:
    "demofiles/flower.htm""demofiles/flower2.htm""demofiles/flower3.htm""demofiles/flower4.htm" 
    i need to use this:

    PHP Code:
      {foreach from=$_PAGES key=page item=_pg}
            
       
    "musik/page={$page}.html",
        
             {/foreach} 


    Is there a way - to do this under the javascript? Sometimes in Div`s?


    Greetings
    Last edited by Linda80; 08-19-2008 at 06:19 PM.

  2. #2
    Join Date
    Aug 2004
    Posts
    9,878
    Thanks
    3
    Thanked 962 Times in 951 Posts
    Blog Entries
    15

    Default

    Warning: Please include a link to the DD script in question in your post. See this thread for the proper posting format when asking a question.
    DD Admin

  3. The Following User Says Thank You to ddadmin For This Useful Post:

    Linda80 (08-18-2008)

  4. #3
    Join Date
    Aug 2008
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Sorry!

    Script: Ajax Pagination script v1.2
    [URL="http://dynamicdrive.com/dynamicindex17/ajaxpaginate/index.htm[/URL]


    please!

    - Linda
    Last edited by Linda80; 08-19-2008 at 06:20 PM.

  5. #4
    Join Date
    Aug 2004
    Posts
    9,878
    Thanks
    3
    Thanked 962 Times in 951 Posts
    Blog Entries
    15

    Default

    Hmm I'm not familiar with the Smarty templates convention. But with regards to using JavaScript to dynamically write out the settingsvar variable of Ajax Pagination script, that's certainly possible, but it won't do you much good if you can't first tell JavaScript the list of files you wish to be added inside its "pages" property. Assuming you have a way, instead of manually defining:


    Code:
    var bookonflowers={
    pages: ["demofiles/flower.htm", "demofiles/flower2.htm", "demofiles/flower3.htm", "demofiles/flower4.htm"],
    selectedpage: 0 //set page shown by default (0=1st page)
    }
    You can use tweak it so each file name (specified using Smarty) is added to the "pages" property separately on its own line, which presumably should make the JavaScript easier to define within your templates environment. So something like:

    Code:
    var bookonflowers={}
    bookonflowers.pages=[] //define array
    bookonflowers.pages[bookonflowers.pages.length]="{smarty_path_to_file1}"
    bookonflowers.pages[bookonflowers.pages.length]="{smarty_path_to_file2}"
    bookonflowers.pages[bookonflowers.pages.length]="{smarty_path_to_file3}"
    bookonflowers.pages[bookonflowers.pages.length]="{smarty_path_to_file4}"
    "
    "
    bookonflowers.selectedpage=0
    DD Admin

  6. The Following User Says Thank You to ddadmin For This Useful Post:

    Linda80 (08-20-2008)

  7. #5
    Join Date
    Aug 2008
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    DD Admin, thank you for your helping post!


    How do you mean this line?

    PHP Code:
    {smarty_path_to_file1

    Did you mean, i can call directly to the template with a link - where i am calling this loop?

    PHP Code:
      {foreach from=$_PAGES key=page item=_pg}
            
       
    "music/page={$page}.html",
        
             {/foreach} 
    The code on top - will list all available pagination url's for my site.


    Is there a way to include my template in the javascript?



    Thanks

    - Linda

  8. #6
    Join Date
    Aug 2004
    Posts
    9,878
    Thanks
    3
    Thanked 962 Times in 951 Posts
    Blog Entries
    15

    Default

    Hi Linda:
    Again, I'm not familiar with Smarty's syntax, so {smarty_path_to_file1} in my code above are just placeholders that should represent the paths of the files to display inside Ajax Pagination script. Deducing from what you just posted above, the actual code may look something like:

    PHP Code:
    {foreach from=$_PAGES key=page item=_pg}
      
    bookonflowers.pages[bookonflowers.pages.length]="{$page}.html"
    {/foreach} 
    DD Admin

  9. The Following User Says Thank You to ddadmin For This Useful Post:

    Linda80 (08-23-2008)

  10. #7
    Join Date
    Aug 2008
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Hallo DD Admin and thank you for your help.



    I was playing around now for 5 days and i can't get.

    The thing is, i can't use the smarty template engine in {literal} tags (it musst be turn around the javascript to get it work).


    Code:
    {literal}
    
    <script type="text/javascript">
    
    var bookonflowers={
    pages: ["demofiles/flower.htm", "demofiles/flower2.htm", "demofiles/flower3.htm", "demofiles/flower4.htm"],
    selectedpage: 0 //set page shown by default (0=1st page)
    }
    
    var mybookinstance=new ajaxpageclass.createBook(bookonflowers, "bookcontent", ["paginate-top", "paginate-bottom"])
    
    </script>
    
    {/literal}

    Last question, is there a way to make it like the Ajax content script?

    Code:
    <div id="bookonflowers">
    "demofiles/flower.htm", "demofiles/flower2.htm", "demofiles/flower3.htm", "demofiles/flower4.htm"
    </div>

    And this will than replace in order to work with the javascript?
    This would make the things easier to work!



    Thanks

    - Linda

  11. #8
    Join Date
    Aug 2008
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    got it now!


    PHP Code:
           <script type="text/javascript">
      {
    literal}
    var 
    bookonflowers={
    pages: [{/literal}{foreach from=$_PAGES key=page item=_pg}{if $page == $THIS_PAGE}"music/page={$page}/",{else}"music/page={$page}/",{/if}{/foreach}{literal}],
    selectedpage//set page shown by default (0=1st page)
    }

     
    var 
    mybookinstance=new ajaxpageclass.createBook(bookonflowers"bookcontent", ["paginate-top""paginate-bottom"])
    {/
    literal}
    </script> 

    Thanks Thanks Thanks

  12. #9
    Join Date
    Aug 2004
    Posts
    9,878
    Thanks
    3
    Thanked 962 Times in 951 Posts
    Blog Entries
    15

    Default

    Great, glad to hear!
    DD Admin

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
  •