 |
 |
 |
 |
 |
| Author |
Message |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2683 Location: Germany |
|
How to split articles and show its parts in a dropdown box |
|
As you know you can split an article into different pages using <!--nextpage-->.
With this little hack you can give each page a description, show these descriptions in a dropdown box and jump to the different pages with the help of this dropdown box.
Instructions:
1. Open inc/show.news.php and find this:
 |  | $page_count = sizeof($row['full']);
$row['full'] = $row['full'][($page ? ($page - 1) : 0)]; |
replace with this:
 |  | $page_count = sizeof($row['full']);
//Start dropdown
for($k=1; $k < $page_count + 1; $k++) {
$page_titles[] = explode('<!--nexttitle-->', $row['full'][$k]);
}
$first_page = explode('<!--firstpage-->', $row['full'][0]);
$next_titles = explode('<!--nexttitle-->', $row['full'][$page-1]);
if($page_count > 1) {
$output = str_replace('[dropdown-header]', '', $output);
$output = str_replace('[/dropdown-header]', '', $output);
$dropdown = '<select onchange="window.location=this.options[this.selectedIndex].value">';
$dropdown .= '<option value="?page=1"'.($page == 1 ? 'selected' : '').'>'.$first_page[0].'</option>';
for($j=2; $j < $page_count + 1; $j++) {
$dropdown .= '<option value="?page='.$j.'"'.($j == $page ? 'selected' :
'').'>'.$page_titles[$j - 2][0].'</option>';
}
$dropdown .= '</select>';
}
else {
$dropdown = '';
$output = preg_replace('/\[dropdown-header\](.*?)\[\/dropdown-header\]/i', '', $output);
}
$output = str_replace('{pages-dropdown}', $dropdown, $output);
//End dropdown
$row['full'] = $row['full'][($page ? ($page - 1) : 0)];
//Start dropdown
$row['full'] = str_replace($first_page[0].'<!--firstpage-->{nl}', '', $row['full']);
$row['full'] = str_replace($next_titles[0].'<!--nexttitle-->{nl}', '', $row['full']);
//End dropdown
|
2. In your full story template add something like this:
 |  | [dropdown-header]Other parts of this article: {pages-dropdown}[/dropdown-header] |
3. In the full story of your article put something like this (Put each of the commands on a new line):
 |  | Introduction<!--firstpage-->
This is the first page of the article. We call it "Introduction".
<!--nextpage-->Internet<!--nexttitle-->
This is the second page of the article. We call it "Internet".
<!--nextpage-->Computer<!--nexttitle-->
This is the third page of the article. We call it "Computer".
<!--nextpage-->Keyboard<!--nexttitle-->
This is the last page of the article. We call it "Keyboard". |
|
|
| Mon Jan 09, 2006 12:47 am |
|
 |
Guest
|
|
|
Please login to hide the ads.
|
|
|
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
 |
 |
 |
|