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.

How to set a dynamic variable in a weblog:entries

April 24, 2008 10:08am

Subscribe [2]
  • #1 / Apr 24, 2008 10:08am

    latte02125

    119 posts

    Does anyone know how I can set a variable in a weblog:entries loop and then use that variable in a conditional {if} statement?

  • #2 / Apr 24, 2008 10:31am

    Ingmar

    29245 posts

    What would you want to achieve by that? There might be a preset variable for you. Failing that, PHP can certainly do that.

  • #3 / Apr 24, 2008 3:54pm

    latte02125

    119 posts

    I have a weblog entries loop where I select 2 different statuses, open and feature.  I was to suppress the first occurance of the feature status since the first featured article will be on the page in a prime location.

    the offset doesn’t seem to be powerful enough to offset against a specific status when working with multiple statuses. So, what i am trying to do is figure out how to test for {status} being ‘feature’ and then not display the first occurance of that but display all others with that status.

    So, I thought if I could set a variable so I know I suppressed the first featured item from displaying.  Then on each loop, I could then use that variable as a test.

    I am open to better ideas, and if I have to use PHP, an example would be very helpful.

    thanks!!!!!
    M-

  • #4 / Apr 24, 2008 6:18pm

    Ingmar

    29245 posts

    In your case, I think, it will have to be PHP. Basically, you would do the following:

    Every time you’d encounter status=“feature” you’d check a counter. If it is 1, you skip that posting, in all other cases you simply increment that counter by 1. Other statuses don’t trigger the code. Am I making sense?

  • #5 / Apr 24, 2008 6:37pm

    latte02125

    119 posts

    Thanks!!!

    I’ve been working on this code, and playing the php buttons.  Here is the logic that I am using.  Thanks for the inspiration! So this will drop the first ‘front_feature’ since that gets a prime spot elsewhere on the page.  All other front_features are displayed becuase the $skip variable get set after the first one…

    <?php 
    if ("{status}" == "front_feature" AND !isset ($skip)) {
    $skip = "1";
    } else { ?>
    
    <!-- start entry -->
    bla bla bla
    <!-- end entry -->
    
    <?php } ?>
  • #6 / Apr 24, 2008 6:41pm

    Ingmar

    29245 posts

    Looks good, at a glance. Have you given it a try? Let us know how it goes.

  • #7 / Apr 24, 2008 10:10pm

    latte02125

    119 posts

    yes!  I just finished it up and it is just loverly.

    you can see it at: http://www.boomercoffeehouse.com/index.php/self_expression/category/C11/

    Thanks again!
    M-

  • #8 / Apr 25, 2008 3:02am

    Ingmar

    29245 posts

    Great it’s working for you 😊

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

ExpressionEngine News!

#eecms, #events, #releases