• Register
    • Help

    striker  0 Items
    Currently Supporting
    • Home
    • News
    • Forum
    • Wiki
    • Support
      • Manage Subscriptions
      • FAQ
      • Support For
        • VaultWiki 4.x Series
        • VaultWiki.org Site
    • What's New?
    • Buy Now
    • Manual
    • 
    • Support
    • VaultWiki 3.x Series
    • Bug
    • Table of Contents (TOC) Order Wrong

    1. Welcome to VaultWiki.org, home of the wiki add-on for vBulletin and XenForo!

      VaultWiki allows your existing forum users to collaborate on creating and managing a site's content pages. VaultWiki is a fully-featured and fully-supported wiki solution for vBulletin and XenForo.

      The VaultWiki Team encourages you to join our community of forum administrators and check out VaultWiki for yourself.

    Issue: Table of Contents (TOC) Order Wrong

    • Issue Tools
      • View Changes
    1. issueid=892 October 20, 2009 12:18 PM
      Elenna Elenna is offline
      Junior Member
      Table of Contents (TOC) Order Wrong

      We created a new wiki article this morning, and the table of contents isn't displaying in the correct order.

      I'll attach a screenshot so you can see, and also include the text of the article.
    Issue Details
    Issue Number 892
    Issue Type Bug
    Project VaultWiki 3.x Series
    Category Headlines / Sections
    Status Fixed
    Priority 3 - Loss of Functionality
    Affected Version 2.5.5
    Fixed Version 2.5.6
    Milestone (none)
    Software DependencyAny
    Users able to reproduce bug 0
    Users unable to reproduce bug 0
    Attachments 2
    Assigned Users (none)
    Tags (none)




    1. October 20, 2009 12:21 PM
      Elenna Elenna is offline
      Junior Member
      Here is the URL for the article:

      http://www.graceofthevalar.com/showw...cies:Mentoring
      Reply Reply  
    2. October 21, 2009 2:24 AM
      pegasus pegasus is offline
      VaultWiki Team
      This was such a pain to fix you have no idea - because there was a variation using H1 in a Book TOC that made it even worse.

      Fixed for the next build. There's a lot of edits, so I recommend waiting, but in vault/special_functions_postbit.php, find:
      Code:
      function table_of_contents(&$parser, $text, &$add_values, $toc_title = false, $shortstop = 0)
      Replace with:
      Code:
      function table_of_contents(&$parser, $text, &$add_values, $toc_title = false, $shortstop = 0, $recurse = false)
      Find:
      Code:
      		$parser->edit_heading += count($vault->parser['toc_addlinks']);
      		$parser->edit_heading += count($add_values);
      Replace with:
      Code:
      		if (!empty($vault->parser['toc_addlinks']))
      		{
      			$addcount = count($vault->parser['toc_addlinks']);
      			$parser->edit_heading += count($vault->parser['toc_addlinks']);
      		}
      
      		if (!empty($add_values))
      		{
      			$parser->edit_heading += count($add_values);
      		}
      Find:
      Code:
      				$headline_list[] = $info;
      
      				if ($info['start_here'])
      				{
      					$last_key = $key;
      					$last_level = $info['level'];
      					unset($info['start_here']);
      				}
      Replace with:
      Code:
      				if ($info['start_here'])
      				{
      					if ($recurse === 0)
      					{
      						$base_level = $info['level'];
      					}
      					else if ($info['baseLevel'])
      					{
      						$base_level = $info['baseLevel'];
      					}
      
      					$last_key = $key;
      
      					if (is_numeric($info['setLevel']))
      					{
      						$last_level = $info['setLevel'];
      
      						if ($info['setLevel'] > 0)
      						{
      							$last_level--;
      						}
      					}
      					else if (!isset($info['setLevel']))
      					{
      						$last_level = $info['level'];
      					}
      					unset($info['start_here']);
      				}
      
      				$headline_list[] = $info;
      Find:
      Code:
      			$info['pos'] = $hpos;
      
      			if ($last_level)
      			{
      				$info['level'] += $last_level;
      			}
      Add after:
      Code:
      			if ($hix == $headline_count - 1 AND empty($vault->parser['toc_addlinks']))
      			{
      				special_toc_shortstop($info, $base_level, $recurse);
      			}
      Find:
      Code:
      			foreach ($vault->parser['toc_addlinks'] AS $key => $info)
      			{
      				if (isset($last_level))
      				{
      					$info['level'] += $last_level;
      				}
      Add after:
      Code:
      				if ($key == $addcount - 1)
      				{
      					special_toc_shortstop($info, $base_level, $recurse);
      				}
      Find:
      Code:
      			$headline_list = array_merge($headline_list, $temp_list);
      Replace with:
      Code:
      			$headline_list = $temp_list;
      Find:
      Code:
      function construct_tocbits($list, $offset = 0, $depth = 1, $depthmark = '')
      Add before:
      Code:
      function special_toc_shortstop(&$info, $base, $recurse)
      {
      	$info['start_here'] = true;
      
      	if ($recurse === 0 OR $recurse === 1)
      	{
      		if (is_numeric($base))
      		{
      			$info['setLevel'] = $base + 1;
      			$info['baseLevel'] = $base;
      		}
      		else if ($recurse === 0)
      		{
      			$info['setLevel'] = 1;
      		}
      		else
      		{
      			$info['setLevel'] = false;
      		}
      	}
      }
      Find:
      Code:
      		if ($list["$hix"]['level'] > $last)
      Add before:
      Code:
      		if (is_numeric($list[$hix - 1]['setLevel']))
      		{
      			if (isset($list[$hix - 1]['baseLevel']))
      			{
      				// use the base level if available
      				$list["$hix"]['level'] = $list[$hix - 1]['setLevel'];
      			}
      			else
      			{
      				// set the h1 equal to highest level from first block
      				$last = $list[$hix - 1]['setLevel'];
      			}
      		}
      Find:
      Code:
      		if ($depth2 < $depth)
      Replace with:
      Code:
      		if ($depth2 < $depth AND $depth != 1)
      In vault/special_class_postbit.php, find:
      Code:
      			$oldsections = $vault->postbit['sections'];
      
      			foreach ($this->post['broken'] AS $i => $messagebit)
      			{
      				if (empty($vault->parser['toc_addlinks']))
      				{
      					$vault->parser['toc_addlinks'] = array();
      				}
      
      				$pre = count($vault->parser['toc_addlinks']);
      
      				$this->post['broken']["$i"] = table_of_contents(
      					$this->bbcode_parser,
      					$messagebit,
      					$headline_list,
      					$toc_title,
      					1
      				);
      
      				$vault->parser['toc_addlinks'] = $headline_list;
      				$headline_list = array();
      				$this->bbcode_parser->edit_heading -= count($vault->parser['toc_addlinks']) - $pre;
      			}
      
      			$headline_list = $vault->parser['toc_addlinks'];
      Replace with:
      Code:
      			$oldsections = $vault->postbit['sections'];
      			$brokencount = count($this->post['broken']);
      
      			if (!empty($headline_list))
      			{
      				$temper = true;
      			}
      
      			foreach ($this->post['broken'] AS $i => $messagebit)
      			{
      				if ($i == 0)
      				{
      					$q = 0;
      				}
      				else if ($i == $brokencount - 1)
      				{
      					$q = 2;
      				}
      				else
      				{
      					$q = 1;
      				}
      
      				$this->post['broken']["$i"] = table_of_contents(
      					$this->bbcode_parser,
      					$messagebit,
      					$headline_list,
      					$toc_title,
      					1,
      					$q 
      				);
      
      				$this->bbcode_parser->edit_heading -= count($headline_list);
      			}
      Reply Reply  
    3. October 23, 2009 9:44 AM
      Elenna Elenna is offline
      Junior Member
      Wow, that is a lot of work. Thank you for fixing it!
      Reply Reply  
    + Reply

    Assigned Users
    Loading Please Wait
    Tags
    Loading Please Wait
    • Contact Us
    • License Agreement
    • Privacy
    • Terms
    • Top
    All times are GMT -4. The time now is 7:21 PM.
    This site uses cookies to help personalize content, to tailor your experience, and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Learn more… Accept Remind me later
  • striker
    Powered by vBulletin® Version 4.2.5 Beta 2
    Copyright © 2023 vBulletin Solutions Inc. All rights reserved.
    Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2023 DragonByte Technologies Ltd.
    Copyright © 2008 - 2013 VaultWiki Team, Cracked Egg Studios, LLC.