Loading...
 
Skip to main content

Development


Several headings in different posts at the same thread

What is the problem?

Better to show than describe...

So...

This is the first "heading" in one post. Hide state.

[+]

This is the second "heading" in one post. Hide state.

[+]

Go to the next post...

Part two...

This is the first "heading" in another post. Hide state too.

[+]

This is the second "heading" in another post. Hide state too.

[+]

And now, try to show all headings in both posts...


The problem is that each message parsed separately by code:

tikilib.php
Copy to clipboard
function parse_data_process_maketoc ... if ($divstate == '+' || $divstate == '-') { // OK. Must insert flipper after HEADER, and then open new div... $thisid = 'id' . ereg_replace('[^a-zA-z0-9]', '',urlencode($options['page'])) .$nb_hdrs;

1. Solution number one:

Generate unique id for every heading:

tikilib.php
Copy to clipboard
function parse_data_process_maketoc ... if ($divstate == '+' || $divstate == '-') { // OK. Must insert flipper after HEADER, and then open new div... $thisid = 'id' . microtime() * 1000000;

For the anchor to allow bookmarks or links we can add another hidden control with old-style id:

tikilib.php
Copy to clipboard
$thisid = "id" . ereg_replace('[^a-zA-z0-9]', '',urlencode($options['page'])) .$nb_hdrs; $aclose2 .= '< div id="' . $thisid . '">';


2. Solution number two:

Use specifics section. For example:

tikilib.php
Copy to clipboard
function parse_data_process_maketoc ... global $section, $comment_info; switch ($section) { case "forums": $id_prefix = str_replace('@','',$comment_info['message_id']); break; }; if (!isset($id_prefix)) $id_prefix = "id"; // OK. Must insert flipper after HEADER, and then open new div... $thisid = $id_prefix . ereg_replace('[^a-zA-z0-9]', '',urlencode($options['page'])) .$nb_hdrs;

3. Solution number three:


Add to Tiki global identifier of any object. For example through the global counter or something like that.

4. Any other solutions???