• Resolved berttervoert

    (@berttervoert)


    Hi Jory,

    I’ve created a pod called ‘Clubleden’, which has a title, featured image, custom field ‘functie’ and custom field ‘lid sinds’. The ‘functie’ field is a simple relationship field with the values: ‘voorzitter’, ‘penningmeester’, ‘secretaris’, ‘bestuurslid’, ‘lid’. The first four are members of the board, which I want to display on a separate page. But I want them to display in a particular order: voorzitter, penningmeester, secretaris, bestuurslid, bestuurslid.

    Do you think this can be achieved with a pods template, or should I go for a php template? I played around a bit with the shortcode to see if I could get the data I wanted and was able to do so with a ‘where’-statement. But (if I’m correct) you can’t use any html markup in the shortcode, so a template will be needed.

    I’ve looked at your videos and other suggestions on the net, but haven’t found an answer to this question. First I thought I could use an [If] statement, but this is only to check if a field is present or not. Could you give me any advice on the sort of template to use for this?

    Tanks in advance,
    Bert.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @berttervoert

    See https://stackoverflow.com/questions/19196475/custom-order-by-in-sql-server-like-p-a-l-h
    You’ll have to create a custom ordering within the shortcode orderby param.

    However, if you want it to display titles in between you really need to use custom PHP templates so you can trigger the generation of these titles between the entries.

    Cheers, Jory

    Thread Starter berttervoert

    (@berttervoert)

    Hi @jory,

    I looked at the example you suggested, but I can’t get the orderby param to work within the shortcode. It either ignores the orderby part all together or it displays nothing and gives an wordpress database error. Might it be so that it isn’t possible to use ‘case’ with the ‘orderby’ statement in the shortcode? And how about the ‘Functie’ value ‘Bestuurslid’, which has two entries?

    The shortcode I tried which seems to ignore the orderby part:

    [pods name=”clubleden” where=”functie.meta_value != ‘Lid'” orderby=”case when functie.meta_value = ‘Voorzitter’ then 1 when functie.meta_value = ‘Penningmeester’ then 2 end”]
    {@post_title}
    (@functie}
    [/pods]

    (I didn’t add all the value for ‘functie’ just for testing purposes).

    Thanks in advance,
    Bert

    Thread Starter berttervoert

    (@berttervoert)

    Hi @jory,

    Update: after playing around some more with the shortcode and looking at the links provided at the example you suggested, I got it working. The shortcode is now as follows:

    [pods name="clubleden" where="function.meta_value != 'Lid'" orderby="FIELD(functie.meta_value, 'Voorzitter', 'Penningmeester', 'Secretaris', 'Bestuurslid')"]
    {@post_title}
    {@functie}
    [/pods]

    Now I’ll have to get it in a template, to get al the necessary html markup in place.

    Thread Starter berttervoert

    (@berttervoert)

    Last update:

    I created a custom shortcode which calls a template-part that outputs the bestuursleden the way I wanted. Here a screenshot of the result so far (not yet styled it completely):

    https://www.dropbox.com/s/wq0a8bv9kwxu2cc/Screenshot_De%20Club.png?dl=0

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @berttervoert

    Thank you for the examples!
    Good to hear you’ve got it working!

    Cheers, Jory

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘pods template or php template?’ is closed to new replies.