WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Post List
[resolved] PHP and shortcodes from other plugin (9 posts)

  1. Nightjar
    Member
    Posted 1 year ago #

    Apologies for starting this same thread here (already posted on ekojr.com)...

    Over the last 9 days I tried to configure APL so to use a shortlink from another plugin (Easy Custom Content Types) to pass data and populate a table.

    The only problem left is that ECCT is sending out date fields as Unix timestamps (i.e. sending out strings like “11404800″ instead of “13 May 1970″). I know that a Unix timestamp date can be converted using the following PHP code:

    date(‘j F Y’, $timestamp);

    I discovered someone else succeeded in running a shortcode inside APL using a custom PHP script:
    http://wordpress.org/support/topic/plugin-advanced-post-list-using-shortcodes-in-list-content-section

    But as I'm not so proficient with PHP, can you please tell me how I should configure the [php_function name="function_name" param=""] shortcode so to make it possible to convert those date entries (timestamps) through ECCT+Advanced Post List?

    Thanks a million for your help!

    http://wordpress.org/extend/plugins/advanced-post-list/

  2. Nightjar
    Member
    Posted 1 year ago #

    OK, I sorted out the date display problem, successfully converting the Unix timestamps.

    However, there is still a BIG issue standing. When I try to make a list of custom fields using this code for the table rows:

    <tr><td><img src="http://mywebsiteurl/wp-content/themes/blocked/includes/scripts/timthumb.php?src=[post_thumb]&w=90&h=40&zc=1&q=80&a=l" style="margin: 0px 2px;" /></td><td><a href="[post_permalink]">[post_title]</a></td><td>[post_meta name="ecpt_modello"]</td><td>[post_meta name="ecpt_nome"]</td><td>[post_meta name="ecpt_seriale-costruttore"]</td><td>[php_function name="sh_code" param="ecpt_field id=#data-consegna#"]</td><td>[php_function name="sh_code" param="ecpt_field id=#data-dismissione#"]</td><td>Da calcolare</td></tr>

    Your plugin just displays a series of fields (the ones generated by the php_function name="sh_code" function) that are all the same. That is, every field of each row is the same as the latest entry of that group.

    I have tried to solve the problem with the ECCT plugin developer, but after a series of tries he gave up writing: According to their documentation, it should work. Unfortunately I really don't know what else to tell you, sorry, not unless the Advanced List developer can come back with a specific reason why it's not working.

    I have even tried to hire a developer in India, but he too failed to solve the problem.

    So, basically now I'm in your hands - I know that creating a table using shortcodes from another plugin should be possible (as explained here) but I don't know what's wrong.

    Can you please help me?

  3. EkoJr
    Member
    Plugin Author

    Posted 1 year ago #

    Main reason I haven't been able to touch on this subject much is because the ECCT plugin is not a free plugin, and that makes it really hard for me to debug and figure out whats going on. Plus, the chances of them giving me access to their plugin is almost zero. So, I feel like I'm just shooting blanks in the dark trying, and just confusing the situation even more.

    Plus, most of the shortcodes I haven't been able to mess with much to fully understand, as you might have noticed with "KALINS_ALLOW_PHP" tag, but I have a project set in the future to modify/fix and add shortcodes.

    ...but I'll give this another round to try and help you out. Everything should work right for individual posts and grabs the data from the page. Btw, what does your php function look like?

  4. Nightjar
    Member
    Posted 1 year ago #

    OK, I forwared your request to ECCT developer, so (who knows?) he may provide you a copy of his plugin for testing. Or at least give you some additiona insights.

    Anyway, I'd appreciate really much if you can help me to get out of this mess...

    As I wrote, your plugin does work beautifully along with ECCT custom fields, provided it only grabs the provided data for each page through your post_meta name shortcode.

    But when I have to handle ECCT shortcodes through APL I must use this kind of code:

    [php_function name="sh_code" param="ecpt_field id=#data-consegna#"]

    Following the directions detailed here.

    So, I've just added this PHP to the function.php of my theme:

    function sh_code($post, $shcd){
       $shcd=str_replace('#','"',$shcd); //needed to parse " marks
       if(function_exists('do_shortcode')){
          $output=do_shortcode('['.$shcd.']');
       }else{
          $output="[error: do_shortcode function doesn't exist!]";
       }
       return $output;
    }

    But using it gives a result like this:

    Entry 1: Custom field 1 OK - Custom field 2 OK - PHP generated from entry 3
    Entry 2: Custom field 1 OK - Custom field 2 OK - PHP generated from entry 3
    Entry 3: Custom field 1 OK - Custom field 2 OK - PHP generated from entry 3

    That is, using the PHP function and the ECCT shortcode just make APL display the data of latest entry repeated for all the lines of the table.

  5. EkoJr
    Member
    Plugin Author

    Posted 1 year ago #

    Ah ok. So it's just the same as the other php function. Well, give me some time to check this out and see whats going on line by line. I may also have to look into the codex too. The problem for me is going to occur once I try to execute a shortcode that isn't available for me.

    So, just so I have this right, ecpt_field is the shortcode in ECCT to access the values, and #data-consegna# is the param for the variable's index which your trying to send/return the value of back. Btw, what is #data-consegna# exactly? A custom field in ECCT?

  6. Nightjar
    Member
    Posted 1 year ago #

    OK, ECCT developer sent me a copy of his plugin for you, so to allow you to make any test you need. But probably it will be better to go on exchanging email messages instead. I can't find yours, but mine is diego [at] cartabianca [dot com].

    And yes, data-consegna is an ECCT custom field (it's in Italian and does mean "delivery date"). It's put into #s because of the requirements of that custom PHP function that allows external shortcodes to run with your plugin.

    The data-consegna field is a date field, with the Unix Timestamp converted as a standard date format.

    Hope this helps - I'm looking forward to receiviing your email message, so I can send you a copy of ECCT plugin.

  7. Nightjar
    Member
    Posted 1 year ago #

    The developer of the original PHP code that allows to use external shortcodes within APL just wrote on this same support forum:

    Are you making a proper "custom type" selection on the Advanced Post List settings header? If so, as I can see, that short code "ecpt_field" is based on a different $post object var than the generic $post used in the loop ..

    Remember that Advanced Post List uses a generic $post reference as shown in the example.

    Perhaps, you should pass the ecpt_field shortcode the $post->ID that is currently received by the sh_code function.

    Maybe this can be of help trying to sort out the problem...

  8. EkoJr
    Member
    Plugin Author

    Posted 1 year ago #

    Yea, I checked out his reply just a min ago. He probably knows more about that function than I currently do. Lately, or majority of the development, I've been focused on getting the bigger stuff upgraded and patched up, and I haven't ran into a situation where I personally had to use the php shortcode.

    He may have the solution, and the sh_code does carry the post object in the param. The id value of the individual posts would also be located $post->ID. The ECCT shortcode could be confused as to what post object your referring to and reverting to a default, but I also haven't had a change to check out the ECCT shortcode function/method.

    Btw, I'm kinda surprised they would lend one out, but it does make things a lot easier for me. So, thank you in that sense, and I'll be replying to you by email.

    Unfortunately though, I haven't gotten around to debugging the php shortcode quite yet. Partly because of a dif. full time job. So, I can't go into full detail yet.

  9. EkoJr
    Member
    Plugin Author

    Posted 1 year ago #

    Well, after looking into it. The function works well, and the $post param in the sh_code are being retrieved like they should, and $post->ID has the correct unique ID as well as the other varibles in the post object, but I didn't see any unique value (ex. ID) being used for the ECCT shortcode function. So I basically just received the same exact shortcode.

    Does the ECCT shortcode have addition params?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic