WordPress.org

Ready to get started?Download WordPress

Forums

IF condition for wordpress dropdown settings api (3 posts)

  1. chibib0
    Member
    Posted 2 years ago #

    Hi,

    I have set up a settings api using this tutorial,
    http://alisothegeek.com/2011/04/wordpress-settings-api-tutorial-follow-up/

    And having this setting which adds a dropdown box to choose between "catalog" and "shopping cart",

    $this->settings['store_type'] = array(
    			'section' => 'general',
    			'title'   => __( '<b>Store Type</b> <a href="#"><img src="http://cdn4.iconfinder.com/data/icons/Sizicons/12x12/question_blue.png" border="0" /></a>' ),
    			'desc'    => __( 'Choose the type of your store' ),
    			'type'    => 'select',
    			'std'     => 'Shopping Cart',
    			'choices' => array(
    				'cart' => 'Shopping Cart',
    				'catalog' => 'Catalog',
    			)
    		);

    I wanted to have an if condition or any solution like,

    if "catalog" is selected {
    // do anything as catalog.
    } elseif "shopping cart" is selected {
    // do anything as shopping cart.
    }

    Please help.

  2. accounts@push
    Member
    Posted 2 years ago #

    you should be using a statement like if ($settings['store_type']== "catalogue") echo 'ect...

    then if your "else" statement is required then its pretty straight forward

    if that doesn't work then id consider reading up on the if and else statements and their parameters

  3. accounts@push
    Member
    Posted 2 years ago #

    actually going back to the code you posted it seems like you've got an array stored within an array - or your trying to do that - id be keeping everything into one array and then just referring to it in the 'if' statement like i posted before - it would be easier to work with.

Topic Closed

This topic has been closed to new replies.

About this Topic