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.

Pagination with Conditionals... works in part, but leaves blank pages.

September 27, 2011 9:24am

Subscribe [4]
  • #1 / Sep 27, 2011 9:24am

    FaithBuilders

    42 posts

    This is what I am trying to do:

    Make certain entries appear when a certain member group is logged in. If an entry has a value for the “retailers_price” field, that entry will appear when a “Retailer” (member group 6) is logged in.

    The code below works to cause the proper entries to appear. But…there are empty pages in the pagination links that correspond to where the entries would be that do not have a value for the “retailers_price” channel field.

    To illustrate:
    Currently, there are 12 pages of a certain category of entries that are visible to anyone visiting the website. However, there should only be about 3 or 4 pages appearing with entries that have a value for the “retailers_price” field. But, even when a “Retailer” is logged in, all 12 pages appear in pagination, though only a few contain entries.

    How can I eliminate those blank links from the pagination?

    Here is the code I am using:

    {if member_group == "6"}
    
     {exp:channel:entries channel="products" limit="10" status="open|featured" paginate="both"}
              
                {if "{retailers_price}"}
              
              {paginate}
           
    Page {current_page} of {total_pages} <span class="paginate_pipe">| </span> {pagination_links}
           
           {/paginate}
             
        <ul> 
         <li>
       
        <div class="product">
        
    [PRODUCT FIELDS ARE HERE]
    
        </div>
        
        </li>
        </ul>
          
          {paginate}
           
    Page {current_page} of {total_pages} <span class="paginate_pipe">| </span> {pagination_links}
           
           {/paginate}
           
           {/if}
           
               {/exp:channel:entries}
               
    {/if}
  • #2 / Sep 27, 2011 2:57pm

    FaithBuilders

    42 posts

    Though I couldn’t get the pagination straightened out in this instance, I did find a better way to list entries specific to a member group so that the pagination would work correctly.

    I made a duplicate entry for each product. These new entries are the same as the old, except that they have a “Retailers” status instead of the default “open”. Then I tweaked the corresponding templates with variations of the following:

    {if member_group == "6"}
        {exp:channel:entries channel="products" limit="10" status="Retailer" paginate="both"}
       list of entries….
        {/exp:channel:entries}
    
    {if:else}
    {exp:channel:entries channel="products" limit="10" status="open|featured" paginate="both"}
       list of entries….
        {/exp:channel:entries}
    {/if}

    Now, when a “Retailer” visits the templates, they see the correct entries. This also made pricing a much simpler task. The only drawback is that there are duplicate entries.

    If anyone has a simple solution for the original request, I’d be glad to hear about it. But, it is no longer a priority and I’m content with using the new system.

    Thanks! ~Sarah

  • #3 / Sep 27, 2011 9:50pm

    Dan Decker

    7338 posts

    Hi Sarah,

    I’m glad you found a solution that is working for you. I’m sorry you had to go through the trouble of duplicating your entries. There really isn’t a solution to the first issue you brought up. Pagination works off of the total number of entries that match the parameters in {ep:channel:entries} Neither of your conditionals would have an effect on the number of entries returned since they weren’t affecting any of the parameters. Is there anything else we can assist you with?

    Cheers,

  • #4 / Sep 28, 2011 9:48am

    FaithBuilders

    42 posts

    Hi Dan,

    Thank you for responding. And yes, there is one other problem, which I recently encountered.

    I tried to login to the front-end of my website with an older (3 or 4 month-old) username, and, instead of giving me the “Thank you for logging in” message, I was redirected to: http://www.faithbuilders.com/member/unpw_update/_5_5 This screen shows the header and footer used for secure pages, but there was no content in between. (see “blank” image and compare to the “register” image)

    Where is the “member/unpw_update/_5_5” template found, and why does it appear with an older username? I’m able to login with other usernames, including the original superadmin. Why is this screen blank and what purpose does it serve?

    This is the code for the login page:

    {exp:member:login_form return="/"}
    
     <label>Username</label>
    
    
     <input type="text" name="username" value=""  maxlength="32" class="input" size="25" /></p>
    
      <label>Password</label>
    
    
     <input type="password" name="password" value="" maxlength="32" class="input" size="25" /></p>
    
     {if auto_login}
    
     <input class='checkbox' type='checkbox' name='auto_login' value='1'  /> Auto-login on future visits
    
     {/if}
    
     <input type="submit" name="submit" value="Submit" class="submit" /></p>
    
     <a href="https://www.faithbuilders.com/member/forgot_password">Forgot your password?</a>
        <a href="https://www.faithbuilders.com/member/register">Member Registration</a>
    
    {/exp:member:login_form}
  • #5 / Sep 29, 2011 12:11pm

    Mark Bowen

    12637 posts

    Hi Sarah,

    Going back a step on this one you could probably get around the problem you’re having there by using the search://body=“pickles” parameter in your Channel Entries Tag.

    Doing something like this should get you what you need :

    {if member_group == "6"}
    
    {exp:channel:entries
            channel="products"
            limit="10"
            status="open|featured"
            paginate="both"
            search:retailers_price="not IS_EMPTY"}
              
    
    {paginate}
    Page {current_page} of {total_pages} <span class="paginate_pipe">| </span> {pagination_links}
    {/paginate}
    
    <ul> 
    <li>
    <div class="product">
    [PRODUCT FIELDS ARE HERE]
    </div>
    </li>
    </ul>
           
    {/exp:channel:entries}
               
    {/if}

    See if that works better for you on the first problem. Also you shouldn’t need to have the two {paginate} code sections in your code as ExpressionEngine will add those in for you due to your using the paginate=“both” parameter. Give that a go and see if it perhaps works better for you?

    Thanks,

    Mark

     

  • #6 / Sep 29, 2011 1:59pm

    FaithBuilders

    42 posts

    Hi Mark,

    Thank you for responding. I’ll give the code a try when I’ve got some time to experiment.

    Do you have any idea what is causing the member/unpw_update/_5_5 template to appear?

    Thanks again,

    ~Sarah

  • #7 / Sep 29, 2011 11:13pm

    Dan Decker

    7338 posts

    Hi Sarah,

    Did you modify password requirements in the interim? Either increasing the length requirement or turning on secure passwords?

  • #8 / Sep 30, 2011 8:10am

    FaithBuilders

    42 posts

    Dan,

    Good catch! I did increase the password length requirement to 8 characters. After dropping the limit back to 5, the username is able to login with its 5 character password.

    Problem solved.

    Thanks!

    ~Sarah

  • #9 / Sep 30, 2011 8:30am

    Sue Crocker

    26054 posts

    Hi, Sarah, just double checking to see if you need anything else in this thread, or are we good to close it?

  • #10 / Sep 30, 2011 9:08pm

    FaithBuilders

    42 posts

    Sue,

    As of right now, I have no other questions. Thank you for checking.

    ~Sarah

  • #11 / Oct 01, 2011 8:32am

    Sue Crocker

    26054 posts

    Closing the thread.. Feel free to start a new thread if you have any more questions.

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

ExpressionEngine News!

#eecms, #events, #releases