Results 1 to 7 of 7

Thread: Ajax tabs content / inserting php function

  1. #1
    Join Date
    Apr 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Ajax tabs content / inserting php function

    1) Script: Ajax tabs content
    2) http://www.dynamicdrive.com/dynamici...axtabscontent/
    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:
    Code:
    <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!

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    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?
    DD Admin

  3. #3
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    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.
    Jeremy | jfein.net

  4. #4
    Join Date
    Apr 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    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

    Code:
    <a href="#" rel="#default" class="selected">Most popular</a>
    calls on the code further down the page

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

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

    Code:
    <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.

  5. #5
    Join Date
    Apr 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Perhaps the php is distracting. Could the ajax tab call on a second div placed on the same page as the first, like this:

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

  6. #6
    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

    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/dynamici...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.
    - John
    ________________________

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

  7. The Following User Says Thank You to jscheuer1 For This Useful Post:

    currantbun (04-20-2009)

  8. #7
    Join Date
    Apr 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    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.

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
  •