Improved spacing for Graphene Slider

  • yeager200

    #3972

    I love this Theme, but there is one thing that annoyed me. When a title of a blog article is too long, when displayed in the slider, it wraps and pushes the “View full post” button down out of view. So I’ve modified the Theme and wonder if you want to put this back into your main source… I edited one file.

    theme-slider.php

    At the top I added a function to take the excerpt and shorten but keep full words.

    function truncateString($string, $limit, $break=".", $pad="...")
    {
    // return with no change if string is shorter than $limit
    if(strlen($string) <= $limit) return $string;
    // is $break present between $limit and the end of the string?
    if(false !== ($breakpoint = strpos($string, $break, $limit))) {
    if($breakpoint < strlen($string) - 1) {
    $string = substr($string, 0, $breakpoint) . $pad;
    }
    }
    return $string;
    }

    Then I modified the Excerpt display section..

    <?php /* The slider post's excerpt */ ?>
    <div class="slider_post_entry clearfix">
    <?php
    if ( $graphene_settings['slider_display_style'] != 'full-post' ){
    if ( strlen(the_title('','',false)) > 40 ) {
    echo truncateString(get_the_excerpt(), 250, " ");
    } else {
    the_excerpt();
    }
    ?>

    Now I never get the “View full post” button disappearing off the slider. You may wish to implement better logic, but this works for me now and would love this to be in the main source so that I don’t have to keep editing it back in after each update.

    yeager200

    #26814

    Oh and for reference, my blog is here. http://portolaplanet.com/

    Mod

    Kenneth John Odle

    #26815

    Yes, that is slightly annoying. What really bugs me is the fact that the “view full post” button hops around.

    If you don’t want to hack core theme files in the meantime, you can also lock the slider button in place by adding this to your child theme stylesheet or custom CSS:

    .slider_items .block-button {
    position: absolute;
    right: 10px;
    bottom: 10px;
    }

    It may interfere with a slightly longer excerpt, but you can adjust for that by changing the slider height.

    Admin

    Syahir Hakim

    #26816

    You can add this to your child theme’s functions.php file to modify the excerpt length for the slider:

    function graphene_custom_slider_excerpt_length(){
    graphene_set_excerpt_length( 35 );
    }
    add_action( 'graphene_before_slider', 'graphene_custom_slider_excerpt_length' );
    Mod

    Kenneth John Odle

    #26817

    Cool! Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Do NOT follow this link or you will be banned from the site!