PDA

View Full Version : Ajax tabs content / inserting php function



currantbun
04-17-2009, 01:44 PM
1) Script: Ajax tabs content
2) http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/
3) Problem:

I've searched and I cant find the way to do this (hope it's here somewhere). The tabs look great and are nearly perfect on my test site but does anyone know if it's possible to repeat the php function in the other tabs (Blogs, Links) in the same way I have inserted it in the first one (Most Popular) and how I should do it:


<ul id="countrytabs" class="shadetabs">
<li><a href="#" rel="#default" class="selected">Most popular</a></li>
<li><a href=" /ajaxtabs/external5.htm" rel="countrycontainer">Blogs</a></li>
<li><a href="/external4.htm" rel="countrycontainer">Links</a></li>
</ul>
<div id="countrydivcontainer" style="border:1px solid gray; width:278px; margin-top: 2px; margin-bottom: 1em; display:block; padding: 10px">
<p><?php _e('Most Popular','custom');?>
<?php akpc_most_popular($limit = 5, $before = '<li>', $after = '</li>'); ?>
</p>
</div>
<script type="text/javascript">
var countries=new ddajaxtabs("countrytabs", "countrydivcontainer" )
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()
</script>

Thanks!

ddadmin
04-17-2009, 08:26 PM
Hmm it's hard to tell what you're trying to accomplish just based on the above. But if I'm correct, this is more of a PHP question than one to do with Ajax Tabs script itself?

Nile
04-17-2009, 08:29 PM
I think he wants the same PHP function in each ajax tab. I would say it's more of an ajax tab question than PHP.

currantbun
04-18-2009, 08:41 AM
Sorry if I haven't been very clear; I'm barely understand my own thinking (!). What I want to do is call a second php function from the same page (rather than externally) the way it's done in the first default <a> link.

In the first, the line


<a href="#" rel="#default" class="selected">Most popular</a>

calls on the code further down the page


<div id="countrydivcontainer" style="border:1px solid gray; width:278px; margin-top: 2px; margin-bottom: 1em; display:block; padding: 10px">
<p><?php _e('Most Popular','custom');?>
<?php akpc_most_popular($limit = 5, $before = '<li>', $after = '</li>'); ?>
</p>
</div>

So could I change the line


<a href=" /ajaxtabs/external5.htm" rel="countrycontainer">Blogs</a>

to refer to another div code placed beneath the first. If that is possible, I'm not really clear how the href, rel and class relates to the javascript


<script type="text/javascript">
var countries=new ddajaxtabs("countrytabs", "countrydivcontainer" )
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()
</script>

Or am I trying to do something that isn't advisable? At the moment I'm using the external links, it works fine.

currantbun
04-20-2009, 08:55 AM
Perhaps the php is distracting. Could the ajax tab call on a second div placed on the same page as the first, like this:


<li><a href="#" rel="#default" class="selected">Tab 1</a></li>
<li><a href="second div" rel="second div">Tab 2</a></li>

<div id="countrydivcontainer" style="border:1px solid gray; width:278px; margin-top: 2px; margin-bottom: 1em; display:block; padding: 10px">
<p>tab1</p></div>

<div id="second div" style="border:1px solid gray; width:278px; margin-top: 2px; margin-bottom: 1em; display:block; padding: 10px">
<p>tab1</p></div>

jscheuer1
04-20-2009, 01:18 PM
It sounds like you want to use PHP to fetch content rather than AJAX. If that's the case, you would want to use the non-AJAX tab script:

http://www.dynamicdrive.com/dynamicindex17/tabcontent.htm

If you want to fetch content via both PHP and AJAX though, neither script will do both. However, as long as the loading time wouldn't be too great (anything fetched via PHP loads as the page loads) anything fetched via AJAX can be fetched via PHP and visa versa. So your page could (theoretically at least) be worked out using either script. It's just a matter of when you want what to load (when you want what to be parsed by the browser).

Also, it should be possible to dispense with javascript entirely and just use PHP, but then the page would need to reload with each tab change.

currantbun
04-20-2009, 03:37 PM
Thanks for that John and the forum, that was what I was looking for. In the meantime I've been using the ajax tabs and I'm very happy with it, so I'll try the non-ajax tabs in another place and see how it goes.