ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Only show results if entry_id has value

July 30, 2014 11:08am

Subscribe [2]
  • #1 / Jul 30, 2014 11:08am

    deswork

    122 posts

    Hi,

    I’m using the Remember Me plugin to gather entry ids so that I can use them in a compare page

    I have this code that shows only products that have their id set with remeber me.

    {exp:channel:entries channel="products" entry_id="{exp:remember_me:get parse='inward'}" parse='inward'}

    However when there are no entry_id set the channel entries shows all products.

    Is there a way to show a no results message if there are no entry_id set.

    Thanks

    Wayne.

     

  • #2 / Jul 31, 2014 2:45am

    Rob Allen

    3118 posts

    That’s a sticky one, the problem is that when there are no entries specified from the remember_me addon that passes an empty value to the entry_id parameter, EE then ignores the parameter and outputs the first 100 entries it finds (normal behaviour).

    I think the solution is to run a conditional on remember_me on the previous page to check if it’s outputting entry ID’s, if it is then you can link through to the results page, if not just hide or disable the link.

  • #3 / Jul 31, 2014 5:45am

    deswork

    122 posts

    Thanks Rob,

    I decided not to use remember me in the end. I used a array generated from the checkboxes on the product page.

    <?php
        if (isset($_POST['compare'])) {
         $compare_id = implode('|', $_POST['compare']);
        } else {
         echo "{redirect='/products'}";
        }
    ?>
    {exp:channel:entries channel="products" entry_id="<?php echo $compare_id ?>"}
  • #4 / Jul 31, 2014 5:51am

    Rob Allen

    3118 posts

    At least you found a solution 😊

    Just turned up a useful conditional which may have also worked

    {if "{exp:remember_me:get}" != ""}
     {exp:channel:entries channel="products" entry_id="{exp:remember_me:get parse='inward'}" parse='inward'}
     ...
    {if:else}
      No results
    {/if}

     

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases