• Resolved polymaker

    (@polymaker)


    Hi everyone. xnau, thanx for great work with Participants Database!

    There’s a problem using function do_shortcode: I need to call [pdb_list] with filters in the end of pdp-single-default.php. Is there’s a way of doing it?

    When using <?php echo do_shortcode(‘[pdb_list filter=”…”]’);?> filter’s not working.

    Thanx in advance
    Konstantin

    http://wordpress.org/extend/plugins/participants-database/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author xnau webdesign

    (@xnau)

    There’s a way to create an URL that includes search terms, so you won’t have to use the do_shortcode thing at all.

    For instance, you want to show only records from the state of California, add these parameters to the URL:

    search_field=state&value=CA&operator=LIKE&submit=Search

    You can only do this on one field at a time with the current version of the plugin.

    Thread Starter polymaker

    (@polymaker)

    Thanx for the answer.

    Please consult how to transform user profile URL (associated with pdb-single-default.php) from “http://example.com/sportsmen?pdb=567&#8221; to “http://example.com/sportsmen?pdb=567&search_field=state&value=CA&submit=Search&#8221;? Where record pdb=567 has ‘state’ value ‘CA’.

    It must be rather stupid question I suppose, be I’m not good at php, sorry.

    Plugin Author xnau webdesign

    (@xnau)

    Well, you’re mixing the functions of two different shortcodes. That example I gave is for the the “pdb_list” shortcode, and tells the shortcode which records to include in the list. The “pdb” value is only used by the “pdb_single” shortcode, which is for the purpose of displaying that one record. Since the ‘pdb’ value is choosing the record to show, there is no need for any search parameters at that point.

    Perhaps if you stated what you are trying to accomplish it would be easier to point you in the right direction.

    Thread Starter polymaker

    (@polymaker)

    Sorry for misunderstanding.

    I have a page containing [pdb_single] showing data of one record (sportsman results at particular competition). I need to add table to that page showing results of that sportsman on other competitions. To have something like “sportsman profile”.

    That’s why in the first message I tried to get for example name of the sportsman in [pdb_single] (in variable $lastname). And after that call do_shortcode with filter like:
    <?php
    echo do_shortcode(‘[pdb_list filter=”.$lastname.”]’)
    ?>

    Plugin Author xnau webdesign

    (@xnau)

    Ah, I see. Yes, you can do this. Try placing your “do_shortcode” in a custom template for your single record. You could put something like:

    <?php echo do_shortcode('[pdb_list filter="id='.$this->participant_values['last_name'].'"]') ?>

    All of the values of the record are available in the $this->participant_values array. You just drop the value you want to match into the filter statement in the shortcode string.

    Thread Starter polymaker

    (@polymaker)

    Yes, I tried to add this code to the custom template of the page.
    But filters and fields’re not working by unknown reason. It places the whole table of shortcode [pdb_list] with standard fields.

    I even tried to add simple filter like
    <?php echo do_shortcode(‘[pdb_list fields=”last_name,city” filter=”last_name=Smith”]’) ?>
    But result is the same – whole table without any filter.

    Plugin Author xnau webdesign

    (@xnau)

    Well, you’ll have to dig deeper to see the problem. I know this works, I tested it before answering. All I can suggest is you take a look at your PHP error logs to see if there is some other problem. Both the “fields” and “filter” attributes require that the field names be valid names, or they will be ignored and you’ll get everything.

    Are you using the latest version of the plugin?

    Thread Starter polymaker

    (@polymaker)

    Yes, version’s 1.4.9.3.
    Error logs show only:
    [03-May-2013 21:00:12 UTC] PDb_List::_build_shortcode_query list query= SELECT p.id, p.last_name, p.first_name, p.club, p.shooting_result, p.sprint_result, p.swimming_result, p.cross_result, p.start_name, p.sprint_pres FROM wp_participants_database p ORDER BY p.date_updated ASC

    last_name, first_name etc are the fields of my database.

    Maybe there’s a system error in wordpress, need to reinstall plugin and try again

    Plugin Author xnau webdesign

    (@xnau)

    Huh, puzzling. Can you provide a link so I can see it? Email it to me if you want it private. support AT xnau.com

    Thread Starter polymaker

    (@polymaker)

    Site page example:
    http://polyathlon-russia.com/sportsmen?pdb=563

    Interesting, it works differently on localhost and on site:
    – on local host it shows only standard [pdb_list] without any filters and fields
    – on site it works perfectly with defined parameters like:
    <?php echo do_shortcode(‘[pdb_list filter=”last_name=Smith” fields=”last_name,first_name,club,start_name”]’); ?>

    but has error when using $this:
    <?php echo do_shortcode(‘[pdb_list filter=”last_name=’.$this->participant_values[‘last_name’].'” fields=”last_name,first_name,club,start_name”]’); ?>

    Error is (displays on the bottom of the page):
    Fatal error: Using $this when not in object context in /home/k.bashevoy/data/www/polyathlon-russia.com/wp-content/themes/pinboard/template-sidebar-content.php on line 16

    Thread Starter polymaker

    (@polymaker)

    Plugin Author xnau webdesign

    (@xnau)

    Sometimes things won’t work the same with localhost because the configuration values will need to be different.

    On the error, that code will only work in a plugin template, because it is only in that context the “$this” is set. You can’t use it in a WP theme template.

    Try it in a custom template for the single shortcode, it will work.

    Thread Starter polymaker

    (@polymaker)

    It works great now. Thanx!

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

The topic ‘Using do_shortcode filters’ is closed to new replies.