Results 1 to 8 of 8

Thread: Multi-Part Content script link

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

    Exclamation Multi-Part Content script link

    1) I am currently using the Multi-Part Content script for some navigation on my site.

    2) http://dynamicdrive.com/dynamicindex...artcontent.htm


    3) I would like to know if there is a way to set up an index page that can link multiple images or text to the corresponding content parts placed in the div tags for the Multi-Part Content script.


    Basically, I want to have my entire content place within the script, but I need a separated page previewing all the content that a user can click a directly link to that specific part of the content placed within the script.


    I did search for this post so if it has previously been answered, please assist me in finding it.

    Thank you,

  2. #2
    Join Date
    Aug 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Any ideas ould be great!

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

    My first idea is that you need to explain what you are looking for in a clearer, more concise fashion. I will try to translate:

    I want to have my entire content placed within the script, but I need a separate page with a menu of all that content.

    A user can click on any link on that menu to load a specific part of the content onto the page and then to switch to that page.

    If I have this about right, you might want to use the tabbed content script:

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

    with the modification developed in this thread:

    http://www.dynamicdrive.com/forums/s...ad.php?t=12105

    The modification was originally developed for the AJAX version of the script but, if you read through the thread, you will see by the end that it is also adapted to the non-AJAX version.
    - John
    ________________________

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

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

    Question

    Thank you for your help, unfortunately that’s not going work.


    I would like to keep the nav links with ‘next’ and ‘forward’


    My question (revised), is there a way to create a thumbnail page (of the content) and have those link directly to the page embedded with the Multi-Part Content script.

    From this point the user could simply navigate with the nav links.

    thanks

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

    Now that I think I know what you want, yes - that could be done in a similar fashion, when I get the chance I will adapt it to that script. The principal is the same, passing a query string to the Multi-Part Content script to tell it which part to load.
    - John
    ________________________

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

  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

    OK, there is one change to the Multi-Part Content script and one change to its markup. Change the script here by adding the red part in place of the 0 that is currently there:

    Code:
    function onloadfunct(){
    getElementbyClass("multiparts")
    partscollect[curpart].style.display="block"
    document.getElementById("formnavigation").style.display="block"
    updatenav()
    }
    Change the markup (HTML portion) by removing the style shown here in red:

    Code:
    <div class="multiparts" style="display: block">
    <p>Content 1 here</p>
    </div>
    
    <div class="multiparts">
    <div>Content 2 here</div>
    </div>
    
    <div class="multiparts">
    <table><td>Content 3</td></table>
    </div>
    Finally, add this script to the head after the Multi-Part Content script:

    Code:
    <script type="text/javascript">
    
    /*Load content from Query script
     *As first seen in http://www.dynamicdrive.com/forums
     *This notice must remain for legal use */
    
    function get(key_str) {
    var query = window.location.search.substr(1);
    var pairs = query.split("&");
    for(var i = 0; i < pairs.length; i++) {
    var pair = pairs[i].split("=");
    if(unescape(pair[0]) == key_str)
    return unescape(pair[1]);
    }
    return null;
    }
    
    if (location.search&&get('dcount')!=null)
    curpart=get('dcount')*1;
    
    </script>
    Now, let's say the page with Multi-Part Content script on it is multi.htm - All you need to do to get a particular content to display when linking to it is to have the href include a query string (red) like so:

    Code:
    <a href="multi.htm?dcount=1">Link Text or Image Tag</a>
    where the 1 refers to which content you wish to be displayed. The content parts are numbered from 0 to one less than however many you have. Zero is the default. If no query string is used, or if you use ?dcount=0 the first content part will be displayed. Use 1 for the second, 2 for the third and so on.
    Last edited by jscheuer1; 09-02-2006 at 09:18 AM. Reason: update fix for string vs. number bug
    - John
    ________________________

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

  7. #7
    Join Date
    Aug 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That is exactly what I wanted and it works wonderfully. Thank you very much, I will try and be clearer next time. I hope this thread will help people in the future.

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

    I just noticed a problem with this modification. What happens is that since the query string is just that, technically a string and not a number, when the script tries to do math with it, there are problems. This can be fixed by adding this (red) to the Load content from Query script:

    Code:
    <script type="text/javascript">
    
    /*Load content from Query script
     *As first seen in http://www.dynamicdrive.com/forums
     *This notice must remain for legal use */
    
    function get(key_str) {
    var query = window.location.search.substr(1);
    var pairs = query.split("&");
    for(var i = 0; i < pairs.length; i++) {
    var pair = pairs[i].split("=");
    if(unescape(pair[0]) == key_str)
    return unescape(pair[1]);
    }
    return null;
    }
    
    if (location.search&&get('dcount')!=null)
    curpart=get('dcount')*1;
    
    </script>
    I'm going to edit the original post to reflect this addition.
    - John
    ________________________

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

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
  •