parse error

Discussion in 'PHP' started by caligrafx, May 13, 2013.

  1. #1
    I need some help with some php code. Where would the errors be in this parse?

    Thanks,
    Adam


    <?php echo do_shortcode('[premium level="1" teaser="no" message="Message to display to those who cannot view the content."]'<?php if (option::get('list_price') == 'on') { ?><?php if ($price != '') { echo "<span>Price: " . $currency.$nice_price . "</span>"; } ?><?php } ?>'[/premium]'); ?>
    PHP:
     
    Last edited: May 13, 2013
    caligrafx, May 13, 2013 IP
  2. wren11

    wren11 Active Member

    Messages:
    89
    Likes Received:
    10
    Best Answers:
    3
    Trophy Points:
    53
    #2
    looks a bit strange, Your starting another php script <? before ending the first.... try this:

            <?       
                echo do_shortcode('[premium level="1" teaser="no" message="Message to display to those who cannot view the content."]');
           
                if (option::get('list_price') == 'on')
                {
                    if ($price != '')
                    {
                        echo "<span>Price: " . $currency . $nice_price . "</span>";
                    }
                }
     
                echo "[/premium]";
            ?>
    PHP:
     
    wren11, May 13, 2013 IP
  3. caligrafx

    caligrafx Active Member

    Messages:
    137
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    83
    #3
    The code script is to hide the price without the premium level 1. It is still showing.

    [​IMG]


    See I had two different scripts working by there self and tried to connect the two with no luck.

    code 1
    <?php echo do_shortcode('[premium level="1" teaser="no" message="Message to display to those who cannot view the content."]This is the premium content[/premium]'); ?>
    PHP:
    code 2
    <?php if (option::get('list_price') == 'on') { ?><?php if ($price != '') { echo "<span>Price: " . $currency.$nice_price . "</span>"; } ?><?php } ?>
    PHP:
     
    caligrafx, May 13, 2013 IP
  4. wren11

    wren11 Active Member

    Messages:
    89
    Likes Received:
    10
    Best Answers:
    3
    Trophy Points:
    53
    #4
    you can't use an else? I don't fully understand the behavior of your script, can you explain in more detail?
     
    wren11, May 13, 2013 IP
  5. caligrafx

    caligrafx Active Member

    Messages:
    137
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    83
    #5
    Sure can... I am using a wordpress plugin called Premium Content to hide a couple of different thing on my site for example... the price for a house the contact information for each house and the location. They would need to register to view this information.

    The plugin has a couple of function that you could use with the shortcode but I don't really understand the way they work. Here is a copy of the whole loop-estate page.


    <div class="clear"></div>
     
    <div id="loop" class="listings posts-3 <?php if (!isset($_COOKIE['mode']) && (option::get('post_layout') == 'Grid')) { echo 'grid'; }  if (!isset($_COOKIE['mode']) && (option::get('post_layout') == 'List')) { echo 'list';}  if($_COOKIE['mode'] == 'list') { echo 'list'; } if ($_COOKIE['mode'] == 'grid') { echo 'grid'; } ?> ">
         
        <?php
            if (is_author()) { wp_get_current_user(); }
     
            $i = 0;
            ?>
     
        <?php if (!is_author()) { ?>
            <?php if (function_exists('dynamic_sidebar')) { dynamic_sidebar('Quick Search Bar'); } ?>
        <?php } ?>
     
        <div class="clear"></div> 
     
        <section id="content">
     
            <?php while ( have_posts() ) : the_post();  $i++; 
                $post_id = $post->ID;
                $bedrooms = get_post_meta(get_the_ID(), 'wpzoom_estate_wpzbedroom', true);
                $bathrooms = get_post_meta(get_the_ID(), 'wpzoom_estate_wpzbathroom', true);
                $post_author = get_post($post_id);
                $author = $post_author->post_author;     
                $price = get_post_meta(get_the_ID(), 'wpzoom_estate_wpzprice', true);
                if ($price != '') { $nice_price = number_format($price , 0 , '.', ','); }
                $currency = option::get('currency');
                ?>
                <article id="post-<?php the_ID(); ?>" <?php if ($i == 3 ) { $i = 0; echo " class=\"last\"";} ?>>
                    <?php if (option::get('list_thumb') == 'on') {
     
                        $permalink = get_permalink( $id );
     
                          get_the_image( array( 'size' => 'post-list', 'width' => 598, 'height' => 186, 'image_class' => 'rounded', 'link_to_post' => false, 'before' => '<a class="list_thumb" href="'.$permalink.'"><span class="hborder"></span>', 'after' => '</a><div class="image_padder"></div>' ) );
                     
                        get_the_image( array( 'size' => 'post-grid', 'width' => 290, 'height' => 187, 'image_class' => 'rounded', 'link_to_post' => false, 'before' => '<a class="grid_thumb" href="'.$permalink.'"><span class="hborder"></span>', 'after' => '</a><div class="grid_padder"></div>' ) );
     
                    } ?>
                    <div class="awr">
                        <div class="entry-header">
        <?   
                echo do_shortcode('[premium level="1" teaser="no" message="Message to display to those who cannot view the content."]');
       
                if (option::get('list_price') == 'on')
                {
                    if ($price != '')
                    {
                        echo "<span>Price: " . $currency . $nice_price . "</span>";
                    }
                }
     
                echo "[/premium]";
            ?>
     
                            <h2 class="entry-title">
                                <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'wpzoom' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
                            </h2>
                        </div><!-- /entry-header -->
                     
                        <div class="entry">
                            <div class="clear"></div>
                        </div><!-- /entry -->
                     
                        <div class="entry-meta">
                            <?php echo option::get('bedrooms'); ?> - <?php echo "" . $bedrooms . "";?> | <?php echo option::get('bathrooms'); ?> - <?php echo "" . $bathrooms . "";?> <br> Contact: <?php the_author_posts_link(); ?>
                             
                            <br><br><?php if (option::get('list_morebtn') == 'on') { ?><span class="readmore"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'wpzoom' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php echo option::get('lang_1') ?></a></span><?php } ?><div class="clear"></div>
                        </div><!-- /entry-meta -->
                    </div><!-- / .content -->
                </article><!-- /#post-<?php the_ID(); ?> -->
                <?php if ($i == 0) {echo'<div class="clear"></div>';} ?>
            <?php endwhile; ?>
     
            <?php get_template_part( 'pagination'); ?>
     
        </section>
        <?php wp_reset_query(); ?>
        <?php get_sidebar(); ?>
     
    </div><!-- / #loop -->
    PHP:
    Here is a list of the function:
    • is_premium( $post_id ) - Returns true if a post is premium.
    • is_user_subscribed( $user_id ) - Check if user is subscribed or not.
    • user_can_view_content( $post_id ) - Returns true if the logged in user can view the post.
    • get_premium_content_level( $post_id ) - Get level of premium content.
    • get_user_subscription_level( $user_id ) - Get users level.
    • get_premium_post_ids() - Returns an array of post ID's.
     
    Last edited: May 14, 2013
    caligrafx, May 14, 2013 IP