SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2007
    Posts
    97
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Simple php syntax but can't find on internet

    This is likely a dumb-a** question for all of you, but I'll be danged if they refer to it ANYWHERE at php.net or other manuals. Wikipedia has nothing.

    What does this mean? "->"?

    Is it an operator or what?

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,136
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    It is used to access members/methods of an object/class.

    So you may have something like this:
    PHP Code:
      class Cat extends Animal
      
    {
        public 
    $Name;
        public function 
    __construct($name)
        {
          
    $this->Name $name;
        }

        public function 
    Speak()
        {
           echo 
    "Meow!";
        }
      }

      
    $cat = new Cat('Tiger');
      echo 
    'Name of Cat is ' $cat->Name '<br /> The cat says ';
      
    $cat->Speak(); 

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2007
    Posts
    97
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Wow. No wonder I didn't find anything.

    So can you explain $this->Name = $name
    and how it works?

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2007
    Posts
    97
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ok, more to the point, how do I set fees to zero for all categories?

    <?php foreach ($fee_options as $fee_option): ?>
    <h4 class="feecategoriesheader"><?php echo sprintf(_x('"%s" fee options', 'templates', 'WPBDM'), $fee_option['category']->name); ?></h4>
    <?php foreach ($fee_option['fees'] as $fee): ?>
    <p>
    <input type="radio" name="fees[<?php echo $fee_option['category']->term_id; ?>]" value="<?php echo $fee->id; ?>"
    <?php echo _wpbdp_is_fee_selected($fee_option['category']->term_id, $fee->id) ? ' checked="checked" ' : ''; ?>>
    <b><?php echo esc_attr($fee->label); ?> <?php echo wpbdp_get_option('currency-symbol'); ?><?php echo $fee->amount; ?></b><br />
    <?php if (wpbdp_get_option('allow-images') && ($fee->images > 0)): ?>
    <?php if ($fee->days == 0): ?>
    <?php echo sprintf(_nx('Listing will run forever and includes %d image.', 'Listing will run forever and includes %d images.', $fee->images, 'templates', 'WPBDM'), $fee->images); ?>
    <?php else: ?>
    <?php echo sprintf(_nx('Listing will run for %d day', 'Listing will run for %d days', $fee->days, 'templates', 'WPBDM'), $fee->days) . ' '; ?>
    <?php echo sprintf(_nx('and includes %d image.', 'and includes %d images.', $fee->images, 'templates', 'WPBDM'), $fee->images); ?>
    <?php endif; ?>
    <?php else: ?>
    <?php if ($fee->days == 0): ?>
    <?php _ex('Listing will run forever.', 'templates', 'WPBDM'); ?>
    <?php else: ?>
    <?php echo sprintf(_nx('Listing will run for %d day.', 'Listing will run for %d days.', $fee->days, 'templates', 'WPBDM'), $fee->days); ?>
    <?php endif; ?>
    <?php endif; ?>
    </p>
    <?php endforeach; ?>
    <?php endforeach; ?>

  5. #5
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,136
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by swmagic View Post
    Wow. No wonder I didn't find anything.

    So can you explain $this->Name = $name
    and how it works?
    That is assigning the parameter of $name to the property $Name which is defined in the class.

    Quote Originally Posted by swmagic View Post
    Ok, more to the point, how do I set fees to zero for all categories?

    PHP Code:
    <?php foreach ($fee_options as $fee_option): ?>
    <h4 class="feecategoriesheader"><?php echo sprintf(_x('"%s" fee options''templates''WPBDM'), $fee_option['category']->name); ?></h4>
    <?php foreach ($fee_option['fees'] as $fee): ?>
    <p>
    <input type="radio" name="fees[<?php echo $fee_option['category']->term_id?>]" value="<?php echo $fee->id?>"
    <?php echo _wpbdp_is_fee_selected($fee_option['category']->term_id$fee->id) ? ' checked="checked" ' ''?>>
    <b><?php echo esc_attr($fee->label); ?> <?php echo wpbdp_get_option('currency-symbol'); ?><?php echo $fee->amount?></b><br />
    <?php if (wpbdp_get_option('allow-images') && ($fee->images 0)): ?>
    <?php 
    if ($fee->days == 0): ?>
    <?php 
    echo sprintf(_nx('Listing will run forever and includes %d image.''Listing will run forever and includes %d images.'$fee->images'templates''WPBDM'), $fee->images); ?>
    <?php 
    else: ?>
    <?php 
    echo sprintf(_nx('Listing will run for %d day''Listing will run for %d days'$fee->days'templates''WPBDM'), $fee->days) . ' '?>
    <?php 
    echo sprintf(_nx('and includes %d image.''and includes %d images.'$fee->images'templates''WPBDM'), $fee->images); ?>
    <?php 
    endif; ?>
    <?php 
    else: ?>
    <?php 
    if ($fee->days == 0): ?>
    <?php _ex
    ('Listing will run forever.''templates''WPBDM'); ?>
    <?php 
    else: ?>
    <?php 
    echo sprintf(_nx('Listing will run for %d day.''Listing will run for %d days.'$fee->days'templates''WPBDM'), $fee->days); ?>
    <?php 
    endif; ?>
    <?php 
    endif; ?>
    </p>
    <?php endforeach; ?>
    <?php 
    endforeach; ?>
    Is $fee_options coming from a database? Are you trying to just NOT show any output from the code below or better yet, what result are you getting now that you want changed?

  6. #6
    Non-Member
    Join Date
    Oct 2007
    Posts
    363
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by swmagic View Post
    Ok, more to the point, how do I set fees to zero for all categories?

    <?php foreach ($fee_options as $fee_option): ?>
    <h4 class="feecategoriesheader"><?php echo sprintf(_x('"%s" fee options', 'templates', 'WPBDM'), $fee_option['category']->name); ?></h4>
    <?php foreach ($fee_option['fees'] as $fee): ?>
    <p>
    <input type="radio" name="fees[<?php echo $fee_option['category']->term_id; ?>]" value="<?php echo $fee->id; ?>"
    <?php echo _wpbdp_is_fee_selected($fee_option['category']->term_id, $fee->id) ? ' checked="checked" ' : ''; ?>>
    <b><?php echo esc_attr($fee->label); ?> <?php echo wpbdp_get_option('currency-symbol'); ?><?php echo $fee->amount; ?></b><br />
    <?php if (wpbdp_get_option('allow-images') && ($fee->images > 0)): ?>
    <?php if ($fee->days == 0): ?>
    <?php echo sprintf(_nx('Listing will run forever and includes %d image.', 'Listing will run forever and includes %d images.', $fee->images, 'templates', 'WPBDM'), $fee->images); ?>
    <?php else: ?>
    <?php echo sprintf(_nx('Listing will run for %d day', 'Listing will run for %d days', $fee->days, 'templates', 'WPBDM'), $fee->days) . ' '; ?>
    <?php echo sprintf(_nx('and includes %d image.', 'and includes %d images.', $fee->images, 'templates', 'WPBDM'), $fee->images); ?>
    <?php endif; ?>
    <?php else: ?>
    <?php if ($fee->days == 0): ?>
    <?php _ex('Listing will run forever.', 'templates', 'WPBDM'); ?>
    <?php else: ?>
    <?php echo sprintf(_nx('Listing will run for %d day.', 'Listing will run for %d days.', $fee->days, 'templates', 'WPBDM'), $fee->days); ?>
    <?php endif; ?>
    <?php endif; ?>
    </p>
    <?php endforeach; ?>
    <?php endforeach; ?>

    You know you really don't need to start each line in php with <?PHP ?>

    That's just going to make editing your code much more difficult.

    To understand the "->" syntax, you should read up on objects.

  7. #7
    SitePoint Enthusiast
    Join Date
    Oct 2007
    Posts
    97
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Well I think the $fee_options are coming from the database. My fear is that if I simply remove this section then the fee will be null rather than zero and I haven't a clue what that would do to the rest of the code, so I thought forcing it to zero would be safer in the greater scheme of things.

    Also when I remove the code, there is another section of code above that is declares invalid as a message comes up
    Please select a fee option for the “Accessories” category. and I didn't want to go too far with this.

    Thus the request to set the fee to zero.

  8. #8
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,136
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Okay, this is a stab in the dark, but couldn't you just update the database column named "fee_amount" or "amount" to 0?

    The problem I see, is if I alter the code you provided, it won't actually alter the submitting of the form, as the form doesn't submit back the "fee_amount", it submits the fee_id, which means it will just look up the amount of the fee from the database again. So you really need to update the database.

  9. #9
    SitePoint Enthusiast
    Join Date
    Oct 2007
    Posts
    97
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Well, the form IS given. Here's the entire function and I was thinking of just forcing the radio button in the form:

    BTW, How do I submit this for greater readability, I don't see [code] anywhere in the toolbar.


    <?php
    function _wpbdp_is_fee_selected($category, $feeid) {
    $fees = isset($_POST['fees']) ? $_POST['fees'] : array();
    return wpbdp_getv($fees, $category) == $feeid;
    }
    ?>

    <?php
    // TODO
    // $html .= __("You have selected more than one category. Each category you to which you elect to submit your listing incurs a separate fee.", "WPBDM");
    // if($wpbusdirman_config_options[$wpbusdirmanconfigoptionsprefix.'_settings_config_6'] == "yes")
    // {
    // $html .=__(" The number of images attached to your listing will be set according to option you choose that has the most images. So if for one category you chose an option with 2 images but for another category you chose an option with 4 images your listing will be allotted 4 image slots", "WPBDM");
    ?>

    <div id="wpbdmentry">

    <div id="lco">
    <div class="title">
    <?php echo !$listing_id ? _x('Submit A Listing', 'templates', 'WPBDM') : _x('Edit Your Listing', 'templates', 'WPBDM'); ?>
    </div>
    <div class="button">
    <?php echo wpbusdirman_post_menu_button_viewlistings(); ?>
    <?php echo wpbusdirman_post_menu_button_directory(); ?>
    </div>
    <div style="clear: both;"></div>
    </div>

    <div class="clear"></div>

    <?php _ex('Step 2 - Quartz Hill does NOT charge members for this directory service...just press Continue below.', 'templates', 'WPBDM'); ?>

    <?php if ($validation_errors): ?>
    <ul id="wpbusdirmanerrors">
    <?php foreach ($validation_errors as $error_msg): ?>
    <li class="wpbusdirmanerroralert"><?php echo $error_msg; ?></li>
    <?php endforeach; ?>
    </ul>
    <?php endif; ?>

    <form id="wpbdp-listing-form-fees" method="POST" action="">
    <input type="hidden" name="action" value="<?php echo $listing_id ? 'editlisting' : 'submitlisting'; ?>" />
    <input type="hidden" name="_step" value="payment" />
    <input type="hidden" name="listing_data" value="<?php echo base64_encode(serialize($listing_data)); ?>" />

    <?php foreach ($fee_options as $fee_option): ?>
    <h4 class="feecategoriesheader"><?php echo sprintf(_x('"%s" fee options', 'templates', 'WPBDM'), $fee_option['category']->name); ?></h4>
    <?php foreach ($fee_option['fees'] as $fee): ?>
    <p>
    <input type="radio" name="fees[<?php echo $fee_option['category']->term_id; ?>]" value="<?php echo $fee->id; ?>"
    <?php echo _wpbdp_is_fee_selected($fee_option['category']->term_id, $fee->id) ? ' checked="checked" ' : ''; ?>>
    <b><?php echo esc_attr($fee->label); ?> <?php echo wpbdp_get_option('currency-symbol'); ?><?php echo $fee->amount; ?></b><br />
    <?php if (wpbdp_get_option('allow-images') && ($fee->images > 0)): ?>
    <?php if ($fee->days == 0): ?>
    <?php echo sprintf(_nx('Listing will run forever and includes %d image.', 'Listing will run forever and includes %d images.', $fee->images, 'templates', 'WPBDM'), $fee->images); ?>
    <?php else: ?>
    <?php echo sprintf(_nx('Listing will run for %d day', 'Listing will run for %d days', $fee->days, 'templates', 'WPBDM'), $fee->days) . ' '; ?>
    <?php echo sprintf(_nx('and includes %d image.', 'and includes %d images.', $fee->images, 'templates', 'WPBDM'), $fee->images); ?>
    <?php endif; ?>
    <?php else: ?>
    <?php if ($fee->days == 0): ?>
    <?php _ex('Listing will run forever.', 'templates', 'WPBDM'); ?>
    <?php else: ?>
    <?php echo sprintf(_nx('Listing will run for %d day.', 'Listing will run for %d days.', $fee->days, 'templates', 'WPBDM'), $fee->days); ?>
    <?php endif; ?>
    <?php endif; ?>
    </p>
    <?php endforeach; ?>
    <?php endforeach; ?>

    <input type="submit" name="submit" class="insubmitbutton" value="<?php _ex('Continue', 'templates', 'WPBDM'); ?>" />

    </form>

    </div>

  10. #10
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,136
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Okay, maybe I should approach this from a different angle, as I still don't see where it is processing the form elements listed on the page. What plugin are you using? As I might be able to download it to see how the code is implemented.

    I also sent you a PM on how to format your code using vbTags.

  11. #11
    SitePoint Enthusiast
    Join Date
    Oct 2007
    Posts
    97
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Odd, really. I go into the database and in the table `wp_wpbdp_listing_fees`, the field 'fee' is a Blob. WTH? The value of those entries I've been tinkering with are [BLOB - 184 B]

  12. #12
    SitePoint Enthusiast
    Join Date
    Oct 2007
    Posts
    97
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    http://businessdirectoryplugin.com/ the free version. I'm building a directory for a chamber.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •