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.

Item page won't show random list of *other* items in same weblog?

May 14, 2011 11:25am

Subscribe [3]
  • #1 / May 14, 2011 11:25am

    FuturShoc

    71 posts

    I’m using EE 1.7.1 (just because the web host only supports PHP 5.0)

    I’m building a retail website with category pages and item detail page. However, on the item detail page, I’d like to add a sidebar of 3 random items from the rest of the catalog as a sort of “You might also be interested in…” feature.

    My problem is that the random list will only ever show the same item being shown on the detail page. I’m pretty sure its because I’m trying to display from the same weblog and the same category, so the EE tags are the same within both the item display code and the random list display code.

    So, I know what’s causing my problem, but my question is: Is there some way around this or am I trying to go about this all wrong?

    Item display:

    {exp:weblog:entries weblog="jewelry"} 
               
               
    
                {categories}
                   <a href="http://{path=products/}">{category_name}</a>
    
                {/categories}
               
    
    
               
                  {ngen_field}
                                                                 
                  <h1>{title}</h1> 
                  
                  {item_description} 
                  ${price} 
                
               {/exp:weblog:entries}

    Random display code (on the same page):

    {exp:weblog:entries weblog="jewelry" orderby="random" limit="3" }
        {title}
    {/exp:weblog:entries}
  • #2 / May 14, 2011 11:32am

    squiid

    39 posts

    Add dynamic=“no” to your exp:weblog:entries tag since you don’t want the URL to affect which items are selected. The dynamic parameter can be difficult to grasp at first but basically by default EE will try and find an entry based on the URL. Turning off this functionality should solve your issue.

    http://ellislab.com/expressionengine/user-guide/modules/channel/parameters.html#par_dynamic

    (these docs are for EE2 but this particular parameter still holds in EE1)

  • #3 / May 14, 2011 11:58am

    FuturShoc

    71 posts

    Thank you for your reply. That makes sense. I noticed that parameter in the documentation, but didn’t realize it applied here.

    ALthough here is my new page code, my behavior remains the same. :-(

    {embed="main/hd"}
    
    <title>
    {exp:weblog:entries weblog="jewelry"} 
       {categories}
           {category_name}
       {/categories}
       | {title}
    {/exp:weblog:entries}    
    </title>
    
    {embed="main/hd2"}
    
    <div class="content_super">
        <div class="container_24 content">
    
        <div class="grid_24">
            
            <div class="grid_4 prefix_1 alpha">
                Logo
    
    
    
    
    
    
    
            </div>
            
            <div class="grid_19 omega">
                Store Photo?
    
    
    
    
    
    
    
            </div>
            
        </div>
        <div class="grid_24">
           <div class="grid_17 prefix_1 alpha">
               
               {exp:weblog:entries weblog="jewelry"} 
               <div class="grid_5 alpha">
                  <h1>{title}</h1> 
                  {item_description} 
       
                  {weight} 
                  Item # {item_number} 
                  
                  ${price} 
                  <div class="other_cat">      
                  Item is in these categories:
                     <ul>
                        {categories}
                           <li><a href="http://{path=products/}">{category_name}</a></li>
                        {/categories}        
                     </ul>
                  </div>
    
               </div>  
               <div class="grid_10 prefix_2 omega">
    
                  {ngen_field}
                  
               </div>  
               {/exp:weblog:entries}    
               
            </div>
            <div class="grid_4 prefix_1 omega impulse_col">
                
                {exp:weblog:entries dynamic="no" orderby="random" limit="3"}
                    {title}
                {/exp:weblog:entries}
                
            </div>
        </div>
        
    </div>
    
    
    {embed="main/ft"}
  • #4 / May 14, 2011 1:08pm

    squiid

    39 posts

    It looks like your entries tag is now missing the weblog name.

    {exp:weblog:entries dynamic="no" orderby="random" limit="3"}

    should be

    {exp:weblog:entries weblog="jewelry" dynamic="no" orderby="random" limit="3"}

    Hope this helps!

  • #5 / May 14, 2011 1:12pm

    FuturShoc

    71 posts

    I hadn’t noticed that, thanks. But re-adding the weblog name hasn’t changed the behavior.

    :-(

  • #6 / May 14, 2011 1:33pm

    squiid

    39 posts

    I just noticed that EE1 has dynamic=“off” instead of dynamic=“no” which is in EE2. See if it’s that simple!

    http://expressionengine.com/legacy_docs/modules/weblog/parameters.html#par_dynamic

    Does this fix it? If not, how many items are in your jewelry weblog? If you got to Output and Debugging Prefs there is an option to show the actual SQL queries. This might give you some insight about what’s happening behind the scenes to give you the same three results every time!

    I don’t know for sure but I’m guessing orderby=“random” translates into a random keyword in the SQL query, so this might help you find this particular line. If you could, it would be helpful to paste that query in this thread 😊

    Shaun

  • #7 / May 14, 2011 1:41pm

    FuturShoc

    71 posts

    dynamic=“off”

    That did it! Thank you!!

  • #8 / May 14, 2011 3:20pm

    squiid

    39 posts

    Great to hear!  For me, the lightbulb moment where the dynamic=“off” thing finally clicked was a huge turning point in my EE world.  It really unlocked the amazingly powerful {exp:weblog:entries} tag and set me free to build (almost) anything imaginable. I hope it does the same for you!

  • #9 / May 14, 2011 3:22pm

    FuturShoc

    71 posts

    Absolutely!

    It so happens that I was having another problem with listing page links in the footer of my site. A problem I was going to come back to later.

    Turns out, dynamic=“off” fixed that problem too!

  • #10 / May 16, 2011 4:47am

    John Henry Donovan

    12339 posts

    Great stuff 😊 Closing this one out. 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