Results 1 to 1 of 1

Thread: Ajax Tabs Question

  1. #1
    Join Date
    Jun 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Ajax Tabs Question

    1) Script Title: Ajax Tabs Content

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...tent/index.htm

    3) Describe problem: Through the use of the SMF (simple machine forum) session, I am hiding or showing a tab based upon if the user is logged in or out. At first, this tab lets call it (user options), just call the external page I wanted with the script on it. However, for security reasons Im too lazy to explain, I have the script inside the default content div. Depending on whether the user is logged in or not, the content of that default div changes. However, my problem is, I have two tabs. The MAIN tab and the OPTIONS tab. Now, when a user is not logged in, the general message shows and the 'user options' tab is not there. However, when they are logged in, the MAIN tab and the OPTIONS tab both show the 'user options' script. So, my question is, is there a way to determine what tab I am on and do something based upon that, or how would I go about showing different content for the different tabs without going calling an external file. In other words, how would i get this script to display ONLY on TAB_4 when they are logged in and the default message on the main tab at all times? Any help would be greatly appreciated.

    page.php
    Code:
    <div id="colFull">
    <h2>TITLE</h2>
    
    <ul id="maintab" class="shadetabs">
    <li class="selected"><a href="#default" rel="ajaxcontentarea">TAB_1</a></li>
    <li><a href="_inc/mediacontent/_TAB_2.php" rel="ajaxcontentarea">TAB_2</a></li>
    <li><a href="_inc/mediacontent/_TAB_3.php" rel="ajaxcontentarea">TAB_3</a></li>
    <li><a href="_inc/mediacontent/_TAB_4.php" rel="ajaxcontentarea">TAB_4</a></li>
    <?php 
    if ($context['user']['is_logged']) {
    echo "<li><a href='#upload' rel='ajaxcontentarea'>TAB_5</a></li>";
    } else {
    }
    ?>
    </ul>
    
    <div id="ajaxcontentarea" class="contentstyle">
    <?php 
    if ($context['user']['is_logged']) {
    ?>
    /*****SCRIPT HERE*****/
    <?php
    } else {
    ?>
    /*****GENERAL MESSAGE HERE*****/
    <?php
    }
    ?>
    </div>
    
    <script type="text/javascript">
    //Start Ajax tabs script for UL with id="maintab" Separate multiple ids each with a comma.
    startajaxtabs("maintab")
    </script>
    
    </div>
    ajaxtabs.js
    Code:
    /*****rest of code *****/
    
    if (url.indexOf("#default")!=-1){ //if simply show default content within container (verus fetch it via ajax)
    document.getElementById(containerid).innerHTML=defaultcontentarray[containerid]
    return
    }
    if (url.indexOf("#upload")!=-1){ //if simply show default content within container (verus fetch it via ajax)
    document.getElementById(containerid).innerHTML=defaultcontentarray[containerid]
    return
    }
    document.getElementById(containerid).innerHTML=loadstatustext
    page_request.onreadystatechange=function(){
    loadpage(page_request, containerid)
    }
    
    /*****rest of code *****/
    An example of what I want to do would be:
    Code:
    <?php 
    if (($context['user']['is_logged']) && (TAB=TAB_4)) {
    ?>
    /*****SCRIPT HERE*****/
    <?php
    } else {
    ?>
    /*****GENERAL MESSAGE HERE*****/
    <?php
    }
    ?>
    </div>
    Last edited by Question; 06-03-2007 at 03:55 PM.

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
  •