WordPress.org

Ready to get started?Download WordPress

Forums

Business Directory Plugin
[resolved] How can I show he content field only? (40 posts)

  1. spikespiegel
    Member
    Posted 1 year ago #

    I don't seem to find out how, I thought I could use "echo $listing_fields;", but it will render all the fields, I just want to display the content field, and need to do that in php.

    Can you help me?

    thx in advance

    http://wordpress.org/extend/plugins/business-directory-plugin/

  2. spikespiegel
    Member
    Posted 1 year ago #

    How can I show the other fields separetely too, I forgot to ask about that, sorry.

  3. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    Hi spikespiegel,

    That's something I'll have to ask my developer. He's defending this thesis this week so he's unavailable at the moment. I'll have to get a response from him next week when he returns.

  4. spikespiegel
    Member
    Posted 1 year ago #

    Ok, I'll be waiting.

  5. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    You can use this function here:

    echo wpbdp_render_listing($listing, 'excerpt');

    where $listing is the post object that represents the listing being shown. The $listing variable can be omitted but in that case the global $post variable should be set to a WPBDP listing or the function will return an empty string. The function is defined in api/api.php.

    That example above would display only the excerpt, for example.

  6. spikespiegel
    Member
    Posted 1 year ago #

    how can I display title, short description and description separetely? Wait, you already said how to display description, what about the other ones?

  7. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    Use the strings "title", "excerpt" (short description) and "description" in the above code separately for those fields.

  8. spikespiegel
    Member
    Posted 1 year ago #

    I tried using:

    echo wpbdp_render_listing($listing, 'title');
    echo wpbdp_render_listing($listing, 'excerpt');
    echo wpbdp_render_listing($listing, 'description');

    and got a weird result, as if the listing was in a mirror, didn't get the result I need, though.

  9. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    Can you please be more specific? For EACH call, what happened? Show the result you got, plus what you expected.

  10. spikespiegel
    Member
    Posted 1 year ago #

    Are you online? I uploaded the site to the server, but I can't stop the service, I need you tell me when you're online, so I make and show you the changes.

    Thx for the support, I'll be waiting for your reply.

  11. spikespiegel
    Member
    Posted 1 year ago #

    here goes the link to a single listing at my site
    http://akecheta.com/free-blogger-templates/469/abstractline/
    you can see what happened after making the changes with the following code:

    echo wpbdp_render_listing($listing, 'title');
    echo wpbdp_render_listing($listing, 'excerpt');
    echo wpbdp_render_listing($listing, 'description');

    in the file businessdirectory-listing.tpl.php

  12. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    I can't tell from your link what the output fields are in that page. Can you surround them with some text to say "Start title" and "End title"?

  13. spikespiegel
    Member
    Posted 1 year ago #

    I did it like this:

    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";

    However, it only shows the "start title" text.
    Take a look at the page again

  14. spikespiegel
    Member
    Posted 1 year ago #

    I made some changes, but revert back, please visit the page now.

  15. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    I only see the "start title" output, the rest of it never shows.

    What exactly are the changes you've made to the template?

  16. spikespiegel
    Member
    Posted 1 year ago #

    deleted $display_fields and made these changes

    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";
  17. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  18. spikespiegel
    Member
    Posted 1 year ago #

    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

  19. spikespiegel
    Member
    Posted 1 year ago #

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

  20. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    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?

  21. spikespiegel
    Member
    Posted 1 year ago #

    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;
    
     ?>
  22. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    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).

  23. spikespiegel
    Member
    Posted 1 year ago #

    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 );

  24. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  25. spikespiegel
    Member
    Posted 1 year ago #

    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' );
  26. spikespiegel
    Member
    Posted 1 year ago #

    I also tried it like this

    $field = wpbdp_get_form_field(4);
    $field->display( $listing_id );
  27. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    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?

  28. spikespiegel
    Member
    Posted 1 year ago #

    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

  29. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  30. spikespiegel
    Member
    Posted 1 year ago #

    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..

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.