PDA

View Full Version : Ajax Pagination script problem



Linda80
08-18-2008, 05:33 PM
Script: Ajax Pagination script v1.2
http://dynamicdrive.com/dynamicindex17/ajaxpaginate/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!


<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>


At these place:


"demofiles/flower.htm", "demofiles/flower2.htm", "demofiles/flower3.htm", "demofiles/flower4.htm"

i need to use this:


{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

ddadmin
08-18-2008, 06:48 PM
Warning: Please include a link to the DD script in question in your post. See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=6) for the proper posting format when asking a question.

Linda80
08-18-2008, 06:52 PM
Sorry!

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


please!

- Linda

ddadmin
08-20-2008, 03:01 AM
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:



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:


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

Linda80
08-20-2008, 06:57 PM
DD Admin, thank you for your helping post! :)


How do you mean this line?


{smarty_path_to_file1}


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


{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

ddadmin
08-20-2008, 10:34 PM
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:


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

Linda80
08-23-2008, 10:10 AM
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).



{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?



<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! :cool:



Thanks

- Linda

Linda80
08-24-2008, 07:28 PM
got it now! :D



<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: 0 //set page shown by default (0=1st page)
}


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


Thanks Thanks Thanks

ddadmin
08-25-2008, 04:38 PM
Great, glad to hear!