[solved] TOC at end of page

More
10 years 11 months ago - 10 years 11 months ago #48181 by gcprnet
Hello, for long articles I use Flexibreak to divide these articles into shorter pages and everything works out fine so far, but I want the TOC to be displayed at the end of the page rather than have it floating in the top right of my article. In the blog template's item_html5.php on line 25 I found the piece of code that seems to "inject" the toc to the articles' so I tried to turn this around and append the toc to the text:
Code:
if (isset($item->toc)) { $item->fields['text']->display = $item->fields['text']->display . $item->toc; }
This doesn't have any effect.
How can I display the TOC at the end of my page, maybe even in a position like "afterdescription?"
I use J! 3.3 with FLEXIcontent version 2.2.0 r1910
Best Regards
Last edit: 10 years 11 months ago by gcprnet.

Please Log in or Create an account to join the conversation.

More
10 years 11 months ago #48217 by ggppdk
Replied by ggppdk on topic [solved] TOC at end of page
Hello

hhmm, yes we have thought of this before and were a little troubled,

because some template did not have this part of code ... ->toc

we are prepending it to the description for compatibility reasons, (we also thought of even using a new field too ... for consistency reasons)


- test this enhancement and then we will commit it (please post back here)

edit flexibreak.php and replace:
Code:
$row->text .= $this->loadTemplate('default_js');
with:
Code:
$toc_placement = $pagenav = $this->params->get('toc_placement', 1); if ($toc_placement) { $row->text .= $this->loadTemplate('default_js'); } else { $row->toc = $this->loadTemplate('default_js'); }

and in flexibreak.xml
Code:
<field name="toc_placement" type="radio" default="1" label="Table of Contents placement" description="You may select to prepend Table of Contents to item's description or placing via item->toc variable in the latter case, please customize item.php/item_htnl5.php of your template</field>"> <option value="0">Output via item->toc variable</option> <option value="1">Prepend to description</option> </field>


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
10 years 11 months ago #48242 by gcprnet
Replied by gcprnet on topic [solved] TOC at end of page
Thank you, this works like a charm. I had to modify the xml a bit, so now it reads:
Code:
<field name="toc_placement" type="radio" default="1" label="Table of Contents placement" description="You may select to prepend Table of Contents to item's description or placing via item-&gt;toc variable in the latter case, please customize item.php/item_html5.php of your template"> <option value="0">Output via item->toc variable</option> <option value="1">Prepend to description</option> </field>
I also made some changes to the plugin's default_js.php file so it now displays page numbers in front of the links and the text of the first link displays the article's title instead of "intro text":
Code:
<?php for ($i = 0; $i < $this->pagescount; $i++) : $page = $this->_generateToc($this->row, $i); if ($display_method == 1) $link = '#'.$page->name; else if ($display_method == 2) $link = $page->link; else $link = '#'.$page->name.'_toc_page'; $active = $this->limitstart == $i ? 'active' : ''; ?> <li> Page <?php echo ($i+1).": ";?><a class="tocLink <?php echo $active ?>" id="<?php echo $page->id ?>" href="<?php echo $link; ?>" onclick="<?php echo $onclick ?>" ><?php if ($i==0) { echo $this->row->title;} else { echo $page->title;} ?> </li> <?php endfor; ?>
just in case anyone is interested in this solution :)
Best regards

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.290 seconds
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save