Viewing 18 posts - 1 through 18 (of 18 total)
  • Author
    Posts
  • #1024241

    Hi,

    I love the style of the new “Table of contents widget” in v4.5.

    How can I show it on top of the content of a post or a page, not in the sidebar?

    Thanks.

    #1025178

    Hey Gitte,

    You can use ALB, load a sidebar inside and load the specific widget :)

    Let us know if you need further help.

    Best regards,
    Basilis

    #1025354

    I would never ever use the ALB for posts! Whenever you switch the theme one day, you have tons of shortcodes in your posts you need to clean up manually!

    So how can I add ENFOLD’s TOC widget in the top of a post’s or page’s content?
    Perhaps a snippet for the loop-index?
    Or better a functions.php snippet?

    #1025691

    Hi,

    Unfortunately, it would require quite some time and customization of the theme to achieve this, so I am sorry to tell you that this is not covered by our support. However, if it’s really important for you to get this done, you can always hire a freelancer to do the job for you :)

    Best regards,
    Basilis

    #1025944

    Where is the Avia Toc code located (in which file), so that I could create a shortcode from it – and how please?
    This is possible, because we had this several times here in the forum concerning other ENFOLD features.

    Thanks.

    #1027394

    Hi,

    This is possible but you have to modify the single.php file.

    Add this code:

    $args = array (
    							'name' => 'Displayed Everywhere',
    							'id' => 'av_everywhere',
    							'description' => '',
    							'class' => '',
    							'before_widget' => '<section id="avia_auto_toc-2" class="widget clearfix avia_auto_toc">',
    							'after_widget' => '<span class="seperator extralight-border"></span></section>',
    							'before_title' => '',
    							'after_title' => '',
    							'widget_id' => 'avia_auto_toc_custom',
    							'widget_name' => 'Enfold Child Table of Contents',
    							);
    
    						$instance = array (
    							'title' => 'Toc',
    							'exclude' => '',
    							'style' => '',
    							'level' => 'h1',
    							'single_only' => 1,
    							'indent' => 1,
    							'smoothscroll' => 1,
    							);
    
    						$toc = new avia_auto_toc;
    						$toc->widget($args, $instance);

    Above line 41:

    get_template_part( 'includes/loop', 'index' );
    

    Yes, you can create a custom shortcode from that.

    Best regards,
    Ismael

    #1027603

    – Thanks a lot, Ismael, it works fine. Could you please tell me, where to add this snippet in – I guess – the loop-index.php (?), so that the TOC is after the featured image and after the post title, but before the content?
    Currently with you snippet, the TOC is above everything (above the featured image resp. post title).
    Is the snippet then valid as you added it above for the loop-index, too, or does it need a modification for that file?

    – And could you please give me a hint, how to make a shortcode out of it please?
    Thank you.

    #1027872

    Hi,

    You can move that code in the includes > loop-index.php file where the post elements reside, right about line 262 where the title is.

    echo $title;
    

    – And could you please give me a hint, how to make a shortcode out of it please?

    The shortcode:

    add_shortcode('avs_toc', 'avs_toc_function');
    function avs_toc_function() {
        $args = array (
            'name' => 'Displayed Everywhere',
            'id' => 'av_everywhere',
            'description' => '',
            'class' => '',
            'before_widget' => '<section id="avia_auto_toc-2" class="widget clearfix avia_auto_toc">',
            'after_widget' => '<span class="seperator extralight-border"></span></section>',
            'before_title' => '',
            'after_title' => '',
            'widget_id' => 'avia_auto_toc_custom',
            'widget_name' => 'Enfold Child Table of Contents',
            );
    
        $instance = array (
            'title' => 'Toc',
            'exclude' => '',
            'style' => '',
            'level' => 'h1',
            'single_only' => 1,
            'indent' => 1,
            'smoothscroll' => 1,
            );
    
        $toc = new avia_auto_toc;
    	return $toc->widget($args, $instance);
    }
    

    You can then use this code to render the toc in the template file:

    
    echo do_shortcode('[avs_toc]');
    

    Or use it directly in the editor.

    Best regards,
    Ismael

    #1028060

    Thank you, Ismael. Can I add your snippet for the shortcode exactly so for showing

    [avs_toc]

    in an ALB text block within a post or page manually?

    I added your snippet

    add_shortcode('avs_toc', 'avs_toc_function');
    function avs_toc_function() {
        $args = array (
            'name' => 'Displayed Everywhere',
            'id' => 'av_everywhere',
            'description' => '',
            'class' => '',
            'before_widget' => '<section id="avia_auto_toc-2" class="widget clearfix avia_auto_toc">',
            'after_widget' => '<span class="seperator extralight-border"></span></section>',
            'before_title' => '',
            'after_title' => '',
            'widget_id' => 'avia_auto_toc_custom',
            'widget_name' => 'Enfold Child Table of Contents',
            );
    
        $instance = array (
            'title' => 'Toc',
            'exclude' => '',
            'style' => '',
            'level' => 'h1',
            'single_only' => 1,
            'indent' => 1,
            'smoothscroll' => 1,
            );
    
        $toc = new avia_auto_toc;
    	return $toc->widget($args, $instance);
    }

    to my Code-Snippets plugin, where all snippets go, that normally go to the functions.php,
    and then added the shortcode [avs_toc] to a text block ALB element in a page, but there is no output at all.

    Are there any changes to the snippet necessary?
    Thanks.

    #1029060

    Hi,

    Yes, you can use that shortcode. And you have to set the “single_only” parameter from 1 to 0 if you want to use it on pages.

    Best regards,
    Ismael

    #1131347

    @ismael

    I have a fresh new installation of the latest ENFOLD at my site and tried to add manually a TOC.

    The only thing I did now is putting this snippet to my Code Snippets Plugin:

    add_shortcode('avs_toc', 'avs_toc_function');
    function avs_toc_function() {
        $args = array (
            'name' => 'Displayed Everywhere',
            'id' => 'av_everywhere',
            'description' => '',
            'class' => '',
            'before_widget' => '<section id="avia_auto_toc-2" class="widget clearfix avia_auto_toc">',
            'after_widget' => '<span class="seperator extralight-border"></span></section>',
            'before_title' => '',
            'after_title' => '',
            'widget_id' => 'avia_auto_toc_custom',
            'widget_name' => 'Enfold Child Table of Contents',
            );
    
        $instance = array (
            'title' => 'Toc',
            'exclude' => '',
            'style' => '',
            'level' => 'h1',
            'single_only' => 1,
            'indent' => 1,
            'smoothscroll' => 1,
            );
    
        $toc = new avia_auto_toc;
    	return $toc->widget($args, $instance);
    }

    Then I added at the beginning of a post manually (I do not want it in every post!!!) this:

    [avs_toc]

    Note: I do not use the ALB for posts and I do not use the Gutenberg editor.

    But nothing is shown – see screenshots below -, although there are h2, h3, h4 headlines in the post.

    Is something wrong with the snippet for ENFOLD 4.5.7?

    View post on imgur.com

    View post on imgur.com

    #1131885

    Hi,

    Thank you for using Enfold.

    Did you add it in a page? If so, try to set the ‘single_only’ parameter to 0. That should enable the widget for pages.

    Best regards,
    Ismael

    #1132283

    No, I added it in a post, not a page in this way, but I have overseen something ;-)

    the TOC is added to the post but ABOVE the featured image, instead of below it:

    This is at the beginning of a post:

    [avs_toc]
    Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. 
    Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. 
    Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem.

    Result:

    View post on imgur.com

    How can I have the TOC really there, where I add the shortcode in a post?
    Normally at the beginning of the actual content …

    —————————————————————————————
    EDIT:
    see private data for my test post at my test installation – here runs ENFOLD v4.6 and it is the same.

    • This reply was modified 5 years, 3 months ago by BeeCee. Reason: private data added
    #1132800

    Hi,

    Thank you for the update.

    This works fine on our own installation. Are you using the special heading elements?

    UPDATE: We set the ‘single_only’ parameter to 0. It works now.

    Best regards,
    Ismael

    #1133001

    @ismael

    Thanks, but I don’t see that it works, sorry, the Table of Content is still above the featured image of the post, instead above the content of the post:

    View post on imgur.com

    Please look above the featured image, there is the TOC and not right above the content, where it belongs and where the shortcode has been added.
    I added the shortcode within the post editor, where it belongs: the TOC should be at the beginning of this post’s content/text:

    View post on imgur.com

    #1133169

    Hi,

    Thank you for the update.

    Yeah, that’s odd. We can’t find the script that’s doing that. What you can do is prepend it back to the “entry-content” container on page load using javascript.

    // https://api.jquery.com/appendTo/

    Best regards,
    Ismael

    #1133321

    Thanks, but I am not a coder, I don’t understand what you mean and what I have to do.

    Isn’t it possible to make changes to your snippet – see private data below?

    #1134789

    Hi,

    We would like to add the script, but the Appearance > Editor panel is not accessible. Please enable it or post the FTP details in the private field. You can try this script in the functions.php file for the meantime.

    add_action('wp_footer', function() {
     ?>
     <script>
       (function($) {
          $(document).ready(function() {
             $('.av_toc_container').prependTo('.entry-content');
          });
       })(jQuery);
     </script>
     <?php
    });

    Best regards,
    Ismael

Viewing 18 posts - 1 through 18 (of 18 total)
  • You must be logged in to reply to this topic.