WordPress.org

Support

Support » Plugins and Hacks » Business Directory Plugin » [Resolved] How can I show he content field only?

[Resolved] How can I show he content field only?

Viewing 15 replies - 16 through 30 (of 39 total)
  • Plugin Author businessdirectoryplugin

    @businessdirectoryplugin

    I think I need to see the whole set of changes you’re putting into that template. The output is just too strange to interpret. Those exact calls are used elsewhere in our code, so I know they work when used in the right context. I would suggest the following:

    – Start with a fresh copy of the original template
    – Make those changes above
    – Post that on your site
    – Post the exact template code you’re using so I can see the context in which you are using this

    That should give a clear picture of the behavior.

    Wouldn’t it be better if I just give you the cpanel login?

    By the way, I tried echo wpbdp_render_listing($listing, ‘excerpt’);, but it only displays the listing as a list, and it displays the full listing.

    The most important thing now is to display just the description, I presume it’s called ‘content’.

    Just that, please help me, my hair is getting white with that already.

    What I need to do is this:

    — Don’t display — Title

    — Don’t display — short description

    — Display — Description

    BY the way, it’s not on the submission form, it’s on the view listing page.

    Thx for the help

    I’m using the plugin default template (Hacking), so that’s probably not a template issue……

    Plugin Author businessdirectoryplugin

    @businessdirectoryplugin

    Showing the template in this case may be important because the context in which you make these calls makes all the difference. Can you please show what you are doing with that template?

    Here goes the full businessdirectory-listing.tpl.php code that I hacked:

    <?php if ($is_sticky): ?>
        <?php echo $sticky_tag; ?>
    <?php endif; ?>
    
    <div class="listing-title">
        <h2 itemprop="name"><?php echo $title; ?></h2>
    </div>
    
    <?php if ($actions): ?>
        <?php echo $actions; ?>
    <?php endif; ?>
    
    <?php if ($main_image): ?>
        <div class="main-image"><?php echo $main_image; ?></div>
    <?php endif; ?>
    
    <div style="height:350px; overflow:auto"
    class="listing-details cf <?php if ($main_image): ?>with-image<?php endif; ?>">
        <?php
    
    //	echo $listing_fields;
    //echo wpbdp_render_listing($listing, 'excerpt' );
    
    echo "start title";
    echo wpbdp_render_listing($listing, 'title');
    echo "end title";
    
    echo  "start excerpt";
    echo wpbdp_render_listing($listing, 'excerpt');
    echo  "end excerpt";
    
    echo "start description";
    echo wpbdp_render_listing($listing, 'description');
    echo "end description";
    
    	?>
    </div>
    
    <?php
    
    echo "start";
    
    echo
    //wpbdp_render_listing($listing, 'content');
    //$listing_fields;
    
    wpbdp_render_listing($listing, 'content');
    
    echo "end";
    
     if ($extra_images): ?>
    <div class="extra-images">
        <ul>
        <?php foreach ($extra_images as $image):  ?>
            <li><?php echo $image; ?></li>
        <?php  endforeach; ?>
        </ul>
    </div>
    
    <?php 
    
    endif;
    
     ?>
    Plugin Author businessdirectoryplugin

    @businessdirectoryplugin

    My developer had this to add:

    The function wpbdp_render_listing is used to render a listing but not just some fields, the whole listing. The function checks the configuration (which fields are enabled, etc.) and receives as second argument the context where the listing is going to be displayed: that context var can be either excerpt or listing and means the listing is to be rendered in excerpt view or single view.
    No other choices are available here so what the user is doing is effectively displaying several times the whole listing (as in single view, since that’s the default).
    But… you can’t configure here which fields to display (it displays what the admin has configured for each context). To manually render a field you have to know which field it is and then render it for a listing. In order to achieve that you use the wpbdp_get_form_fields function (if you are unsure about the ID of the field and want to search by association or other args) or wpbdp_get_form_field if the ID is known. The ID can be figured out using the “Manage Form Fields” admin section and looking at the ID argument of the links in there. For instance, if the ‘title’ ID is 1 and you want to render it you can use the following:

    $field = wpbdp_get_form_field( 1 );
    $field->display( $listing_id );

    If you don’t know which ID it is and you want to obtain the fields by association, for instance, the same thing could be achieved with this:

    $field = wpbpd_get_form_fields( 'association=title&unique=1' );
    $field->display( $listing_id );

    You can change ‘association’ here to be title, content, excerpt, tags or category and you’ll get the respective fields. If you use association=meta you’ll get all the meta fields (or the first one if unique is specified).

    Neither of the codes works.

    In the last one I tried it like this: $field = wpbpd_get_form_fields(‘association=content&unique=4’);
    $field->display( $listing_id );

    Plugin Author businessdirectoryplugin

    @businessdirectoryplugin

    4 may or may not match a field code you have. How did you come up with 4? You should look under Manage Form Fields and hover over the field you want and see what shows up in the URL on the status bar.

    Also, it matters WHERE you are calling that function above, as $listing_id must be valid as well.

    My form field id is 4, I saw it in the status bar and in the database, however, I still can’t put it to work. I tried it like this:

    $field = wpbpd_get_form_fields( 'association=title&unique=1' );
    $field->display( $listing_id='4' );

    and like this:

    $field = wpbpd_get_form_fields( 'association=content&unique=1' );
    $field->display( $listing_id='4' );

    I also tried it like this

    $field = wpbdp_get_form_field(4);
    $field->display( $listing_id );

    Plugin Author businessdirectoryplugin

    @businessdirectoryplugin

    The first suggestion we gave is the correct one, none of these above is right. Can you show how it’s used in full context of the page?

    I dont get you, you mean how am I building the page?

    I basically want to display each field separately, I suppose if I learn how to display one, I’ll be able to display the other ones, right?

    My field id is 4.

    So shouldn’t I use $field = wpbdp_get_form_field( 4 ); to get the field by id, then $field->display( $listing_id ); to display the field?

    Does $listing_id work by itself or do I need to specify something in front of it, cause I used it as it is, turned on the debug mode and I got the following error:

    Notice: Undefined variable: listing_id in D:\xampp-FINAL\htdocs\novosuachance\wp-content\plugins\business-directory-plugin\templates\businessdirectory-listing.tpl.php on line 24

    Plugin Author businessdirectoryplugin

    @businessdirectoryplugin

    This should work:

    $field = wpbdp_get_form_field( 4 );
    $field->display( $listing_id );

    But since I can’t see in which template you’re using or the full context of how it’s being used, I can’t say why it’s not working. $listing_id must be a valid variable as well. Your syntax error above indicates that you’re using it improperly. You may benefit from having a developer assist with your changes–you might consider hiring someone from http://odesk.com to help you more directly.

    Sorry for the delay, I have been very busy and didn’t have time to reply.

    I’m using it in the default template, the one that already comes with the plugin, it is businessdirectory-listing.tpl.php, I even pasted its content here.

    What you mean by $listing_id must be a valid variable?

    Sorry for bothering you so much, that’s the last step of my project..

    Plugin Author businessdirectoryplugin

    @businessdirectoryplugin

    What I’m saying is that you must use the code above in the right section of the template. You can’t just paste it in anywhere, as it won’t work. The $listing_id variable is defined within a certain scope of the template’s execution, which is why I need to see the exact entire template code that you are currently using, to know what is wrong.

    This sounds like a simple programming error, but without seeing the template, I can’t tell you what the exact problem is. I know you posted it already, but since you have changed it afterward, I need the exact, current copy.

Viewing 15 replies - 16 through 30 (of 39 total)
  • The topic ‘[Resolved] How can I show he content field only?’ is closed to new replies.
Skip to toolbar