• Resolved incubouk

    (@incubouk)


    Hi; firstly thank you very much for this brilliant plugin. I do have a couple of queries regarding the Single Record page though – the one that uses the [pdb_single] shortcode.

    1. Is is possible to hide certain fields from the Single Record page, perhaps by attaching “hide=field” parameters to the shortcode or something? I daren’t try it myself in case I break something! I want to prevent email and phone fields from showing for privacy purposes.

    2. The layout of the front-end page for Single Records (i.e. the one that anyone can view by clicking a link on the List) doesn’t seem to display quite right; the field and corresponding value are offset, and there are large gaps between the rows, something like this (without the dots, I’ve just put those in to format it):

    ……………………John
    First Name:
    .
    .
    .
    ……………………Smith
    Last Name:
    .
    .
    .
    ……………………British
    Nationality:

    Is this how it generally looks for everyone, or have I got something set up wrong? I’ve tested it on Chrome and IE and it’s the same on both. The demo on your own page looks how I would expect it to, so I’m hoping there’s something I can do to make it look like that.

    Thank you in advance for your help.

    http://ww.wp.xz.cn/extend/plugins/participants-database/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Roland Barker

    (@xnau)

    incubouk,

    Take a look at the single record template, it explains how to exclude fields using a custom template. Info on how to use templates will be found here: http://xnau.com/work-2/wordpress-plugins/participants-database/using-the-participants-database-plugin/#templates

    The layout of the shortcode output will be affected by your theme stylesheet. You will need to inspect the elements (using something like FireBug on Firefox) to see how the stylesheet CSS is affecting it, then create rules to make it look the way you want it to.

    –Roland

    Thread Starter incubouk

    (@incubouk)

    Thank you very much for your quick reply Roland, and apologies for not noticing the ‘Single Record Templates’ section – that’s exactly what I was looking for. I read through all the help notes several times, but somehow managed to overlook the bit I needed every time!

    The stylesheet / CSS business is all above me unfortunately. I’m using the Graphene theme; if there’s anyone else out there who uses that theme and this plugin, and has worked out how to fix the layout of the Single Record page, I’d be very grateful if you could let me know.

    Many thanks.

    Plugin Author Roland Barker

    (@xnau)

    incubouk,

    This is a pretty standard layout for definition lists, which is the HTML structure used in the single record template.

    What do you want it to do? If you share a link so we can see it, it’s a lot easier to help.

    Thread Starter incubouk

    (@incubouk)

    All I’m looking for is for the field value to align to the field name, and for the rows to be closer together – just like it is on your demo page.

    This is how it currently looks on my site: http://www.incubo.org.uk/national-employment-database/recruiters/employee-record/?pdb=1326

    You’ll see what I mean, the layout is just a bit off for some reason. Thanks again for your help Roland.

    Plugin Author Roland Barker

    (@xnau)

    The fix is pretty simple: your theme stylesheet is adding a 10px margin to the top of the ‘dt’ elements. The change needs to be in your theme stylesheet. Either get rid of the rule altogether or override it with a rule that uses the wrap class of the shortcode:

    .entry-content .pdb-single dt { margin-top:0 }

    I suggest you check out Firefox with the FireBug extension….great way to learn how CSS works.

    Thread Starter incubouk

    (@incubouk)

    That works perfectly; thank you so much Roland, you’re a legend.

    Plugin Author Roland Barker

    (@xnau)

    Len,

    Have you created a custom template by copying the default template (templates/pdb-single-default.php) into your theme directory? If not, this is the first step. Then, look at the file you copied, the plugin will use this file to show the record. In that file, you’ll see that array I’m talking about.

    Check the docs about creating templates, that should help you get set up.

    Plugin Author Roland Barker

    (@xnau)

    Hi Len,

    Yes, I got your donation, thanks very much!

    So, for starters, I want to make sure you’ve got your template set up right. Your template should be a copy of the plugin template “pdb-single-default.php” and it should go into your theme directory in a directory named templates: /wp-content/themes/YOUR_THEME/templates/pdb-single-default.php

    The [pdb_single] shortcode will now be using this file.

    In the file, you will see the exclude array definition at the top. The easiest way to do what you want is to define the array based on the login status of the user. Replace the array declaration with something like this:

    if (is_user_logged_in()) {
       $exclude = array(); // this shows all the fields
    } else {
       $exclude = array('sign-up date', 'membership_level', 'username', 'password', 'age,address', 'address_2', 'zip', 'pone', 'mobile_phone', 'email_2', 'Skype', 'mailing_list', 'interests', 'business_name', 'occupation', 'reason_for_joining', 'other_reasons', 'how_did_you_hear', 'other', 'comments', 'approved', 'volunteered', 'ipa_credit', 'impress_credts', 'ipa_gold_credit', 'impress_gold_credit'); // hide these fields from other users
    }

    Laying out the page is up to the WP theme, so you’ll have to edit your theme CSS to change the way it looks.

    I do suggest you delete any fields you are not using.

    The date format MM/DD/YYYY is a little bit problematic, PHP likes dates which contain a text month much better, but you can use that format if you use the “Strict Dates” setting.

    Plugin Author Roland Barker

    (@xnau)

    lenrapp,

    You meed to move your array definition up to the top of the template and replace the one that is there. It has to be defined before the loop begins.

    Either I am dumb as a stump or I am doing something wrong…

    Here is the code now that I moved the array up on top. What am I missing now…

    ====================================================

    backticks

    <?php
    /*
    * default template for displaying a single record
    *
    * this is the new “WordPress style” template
    *
    * each group with the “visible” attribute checked will display its fields in the order set
    * in the manage database fields page.
    *
    * if there are specific fields you wish to exclude from display, you can include the “name” value of
    * the field in the $exclude array like this: $exclude = array( ‘city’,’state’,’country’ ); or whatever
    * you want. Leave it empty (like it is here) if you don’t want to exclude any fields.
    *
    * this template is a simple demonstration of what is possible
    *
    * for those unfamiliar with PHP, just remember that something like <?php echo $group->name ?> just prints out
    * the group name. You can move it around, but leave all the parts between the <> brackets as they are.
    *
    */

    // define an array of fields to exclude here

    // skip any field found in the exclude array
    if ( in_array( $this->field->name, $exclude ) ) continue;

    $exclude = array( ‘sign-up date’, ‘membership_level’, ‘username’, ‘password’, ‘age’,’address’, ‘address_2’, ‘zip’, ‘phone’, ‘mobile_phone’, ’email_2′, ‘Skype’, ‘mailing_list’, ‘interests’, ‘business_name’, ‘occupation’, ‘reason_for_joining’, ‘other_reasons’, ‘how_did_you_hear’, ‘other’, ‘comments’, ‘approved’, ‘volunteered’, ‘ipa_credit’, ‘impress_credts’, ‘ipa_gold_credit’, ‘impress_gold_credit’ );

    // CSS class for empty fields
    $empty_class = $this->get_empty_class( $this->field );

    ?>

    <div class=”wrap <?php echo $this->wrap_class ?>”>

    <?php while ( $this->have_groups() ) : $this->the_group(); ?>

    <div class=”section” id=”<?php echo Participants_Db::$css_prefix.$this->group->name ?>”>

    <?php $this->group->print_title( ‘<h2>’, ‘</h2>’ ) ?>

    <?php $this->group->print_description( ‘<p>’, ‘</p>’ ) ?>

    <?php while ( $this->have_fields() ) : $this->the_field();

    // CSS class for empty fields
    $empty_class = $this->get_empty_class( $this->field );

    ?>
    <dl class=”<?php echo Participants_Db::$css_prefix.$this->field->name.’ ‘.$this->field->form_element.’ ‘.$empty_class?>”>

    <dt class=”<?php echo $this->field->name.’ ‘.$empty_class?>”><?php $this->field->print_label() ?></dt>

    <dd class=”<?php echo $this->field->name.’ ‘.$empty_class?>”><?php $this->field->print_value() ?></dd>

    </dl>

    <?php endwhile; // end of the fields loop ?>

    </div>

    <?php endwhile; // end of the groups loop ?>

    </div>backticks

    See for yourself, it is still showing the full record.

    Can you make the change in the above and just post it so I can simply copy it and try it?

    Thanks for your patience. Now if this works, I will still want to be able to pull the full record for my use. This one will be for public viewing.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Single Record – [pdb_single] – Hide Fields & Layout Issue’ is closed to new replies.