Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #17674

    Hi,

    I’m very sorry, but I need again your help concerning custom/individual excerpts in CORONA – and I mean the individual, custom excerpt texts, that you can add in the field below the post editor field:

    Currently I have in my functions.php this code, and in my index-loop.php this code:

    <!-- if there is an individual excerpt, show it, otherwise do nothing -->
    <?php if(!empty($post->post_excerpt)) {
    echo '<div id="textauszug">';
    the_excerpt();
    echo '</div>';
    } ?>

    <?php
    if(strpos($avia_config['layout'], 'medium_image sidebar') !== false) echo $slider->display_small('blog');
    if(!is_single()){
    the_excerpt(__('Read more ?','avia_framework'));
    echo '<a class="more-link" href="'. get_permalink().'">'.__('Read more →','avia_framework').'</a>';
    }else{
    the_content(__('Read more ?','avia_framework'));
    }

    This works fine on my frontpage (= created with a dynamic template), on other pages created with dynamic templates, where I grab 3 of the latest blog posts of a certain category for example – but using the “columns” element for grabbing the posts:

    But:

    I have created a dynamic template for a blog overview page; it shows a page’s slideshow and intro text and then – as another dynamic template element – the “blog” element, grabbing 3 of the latest blog posts:

    live:

    So far, so good. The only thing is, that there – and only at this blog overview page (created with dynamic template) – my custom/individual excerpt is shown twice.

    I have nearly no idea of PHP and most is done by try&error ;-)

    So could you please help me out – I guess, something in the loop-index.php code is wrong, OR something needs to be added in another file, so that on such a dynamic template using the element “blog”, the custom excerpt is only shown once, as it does on other normal pages using dynamic templates.

    But I need to mention, that on the frontpage and other content pages, where grab blog posts, I use within the template builder the “columns” element! And for this – wrong – blog overview page, I use within the template builder the element “blog”!

    Only at this page, the custom excerpt is shown twice:

    On the frontpage and on other content pages, for which I used dynamic templates with COLUMNS to grab the posts, the custom excerpt is shown right – once a time:

    Thanks, appreciate your help again concerning this subject.

    #96391

    I just discovered, that not only at the blog overview page (generated with dynamic template and the “blog” element) my custom/individual excerpt is double, but also on the single post view:

    Maybe something with my custom excerpt code (see above) is wrong (= double)?

    #96393

    Hi,

    Off the top of my head, please make sure that your return 50; actually returns what you expect it to return and not just TRUE. Since return 0; will return FALSE and not the number 0. Since the code uses !== , you are are checking for both value and type.

    To make sure it executes only one time create a variable $already_executed=1; and use it to make sure that this section of code is only executed one time.

    <?php if(!empty($post->post_excerpt) && !isset($already_executed))
    {
    echo '<div id="textauszug">';
    the_excerpt();
    echo '</div>';
    $already_executed = "yes";
    } ?>

    Thanks,

    Nick

    #96394

    thanks, Nick, but sorry, I understand not a single word of what you’ve written. Please note, I do not know any PHP – I always use your codes and copy/paste. So I don’t know what is and where to put $already_executed=1

    I have now changed my code with yours, and now my loop-index.php is this:

    <!-- if there is an individual excerpt, show it, otherwise do nothing -->
    <?php if(!empty($post->post_excerpt) && !isset($already_executed))
    {
    echo '<div id="textauszug">';
    the_excerpt();
    echo '</div>';
    $already_executed = "yes";
    } ?>
    <?php
    if(strpos($avia_config['layout'], 'medium_image sidebar') !== false) echo $slider->display_small('blog');
    if(!is_single()){
    the_excerpt(__('Weiterlesen →','avia_framework'));
    echo '<a class="more-link" href="'. get_permalink().'">'.__('Weiterlesen →','avia_framework').'</a>';
    }else{
    the_content(__('Weiterlesen →','avia_framework'));
    }

    This works only partly.

    a) Frontpage (created with dynamic template by using the “column” element in dynamic template builder to grab the blog posts = okay, showing only one time the custom/individual post excerpt:

    b) Another page (created with dynamic template by using the “column” element in dynamic template builder to grab the blog posts = okay, showing only one time the custom/individual post excerpt:

    c) Blog OVERVIEW PAGE (created with dynamic template by using the “blog” element in dynamic template builder to grab the blog posts = NOT okay, showing TWICE time the custom/individual post excerpt:

    Could it be, that the double custom excerpt results in the fact, that I use there the blog element within the template builder?

    In the other 2 cases, I use the “column” element within the template builder – and there all is okay (see the screenshot in my first post here)?

    Please look here for a screenshot with descriptions:

    http://i47.tinypic.com/2rx8nds.jpg


    [EDIT]

    I’ve been testing around with the code in the loop-index.php, but I’m not sure what I’m doing ;-)

    I have reduced the relevant part of code to this now (found somewhere here in a forum from “Dude”):

    <?php
    if(strpos($avia_config['layout'], 'medium_image sidebar') !== false) echo $slider->display_small('blog');
    if(!is_single()){
    the_excerpt(__('Weiterlesen →','avia_framework'));

    echo '<a class="more-link" href="'. get_permalink().'">'.__('Weiterlesen →','avia_framework').'</a>';
    }else{
    the_content(__('Weiterlesen →','avia_framework'));
    }

    This works fine on frontpage, on other pages grabbing posts with template builder, no matter if with “blog” or with “column” element within it.

    The only thing that is not working with this code, is, that the single post does not show my custom excerpt, that I’ve written in the excerpt box below my text editor.

    Maybe this is now only a small problem and easy to solve?

    #96395

    Hey guys, I’m happy … I guess, I have more luck than brains ;-)) I only had an 8 hours training in PHP, but it seems I’m really cool in combining ;-) In a nutshell, I have combined the code at the very first post with try&error and now it looks like this:

    <?php
    if(strpos($avia_config['layout'], 'medium_image sidebar') !== false) echo $slider->display_small('blog');
    if(!is_single()){
    the_excerpt(__('Weiterlesen →','avia_framework'));</p>
    <p>echo '<a href="'. get_permalink().'">'.__('Weiterlesen →','avia_framework').'</a>';
    }else{
    echo '<div id="textauszug">';
    the_excerpt();
    echo '</div>';
    the_content(__('Weiterlesen →','avia_framework'));
    }

    And now it seems to work:

    - at frontpage with template builder (using “columns”):

    - at blog overview page with template builder (using “blog” element):

    and … tatataaaa … my styled custom excerpt in single post view:

    I guess you are now also happy, that the “pain in the neck” has found it out by herself ;-)

    Thanks guys for your patience and helpfulness all the days! Have a nice weekend!

    #96396

    Hi,

    Congratulations you’re a natural. Hacking the code is the way most of us start and go from there. Thanks for putting up the process you followed and the end result.

    Thanks,

    Nick

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

The topic ‘CORONA: Custom post excerpt is on dynamic template page with BLOG OVERVIEW 2x’ is closed to new replies.