PDA

View Full Version : Multi-Part Content script link



rstar
08-29-2006, 10:35 PM
1) I am currently using the Multi-Part Content script for some navigation on my site.

2) http://dynamicdrive.com/dynamicindex17/multipartcontent.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,

rstar
08-30-2006, 07:22 PM
Any ideas ould be great!

jscheuer1
08-31-2006, 08:49 AM
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/dynamicindex17/tabcontent.htm

with the modification developed in this thread:

http://www.dynamicdrive.com/forums/showthread.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.

rstar
09-01-2006, 12:32 AM
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

jscheuer1
09-01-2006, 06:15 PM
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.

jscheuer1
09-01-2006, 10:19 PM
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:


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:


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


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


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

rstar
09-01-2006, 10:56 PM
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.

jscheuer1
09-02-2006, 09:17 AM
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:


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