• Resolved JLBA

    (@jltest)


    Hello,
    I’m using pods for the first time.

    I need to display a list of machines. I created a field Category with a simple list : Cat A, cat B, cat C…

    How can I make the list to display the category (if not empty) then the machines as a sublist.

    example :
    cat A
    – machine
    – machine
    cat C
    – machine
    – machine
    – machine

    (Cat B is not diqplayed as it is empty).

    WP 5.8.1 – Pods 2.8.3

    Thanks

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

    (@keraweb)

    Hi @jltest

    You could create a Pod template for each category listing and render all machines within that template with an each loop: https://docs.pods.io/displaying-pods/template-tags/each-loop-tag/

    You can use a Pod shortcode to load all categories.

    Example code for the template:

    [if machines]
      {@title}
      [each machines]
        {@title}
      [/each]
    [/if]

    The first title is the category title which is only shown when the machines field is filled.
    The second title are all machines.
    This code still required HTML markup etc.

    Cheers, Jory

    Thread Starter JLBA

    (@jltest)

    Thanks Jory. I’ll test it.

    But the categories could change. Some should be added.

    So i’m loking for a template that displays the actual categories and “sub-displays” the according machines.

    Can we use an each inside an each ?

    Thread Starter JLBA

    (@jltest)

    Hi again,
    This don’t work as i’m probably missing something.

    My pod Machines :
    – post_title (as machine name)
    – post_content (as machine description)
    – type (as categorie ; relation ; simple)
    – some other custom fields.

    I need to list the machines by type :
    – <h2>type 1</h2>
    — machine
    — machine
    – <h2>type 2</h2>
    — machine

    And so on.

    • This reply was modified 3 years ago by JLBA.
    Thread Starter JLBA

    (@jltest)

    Sorry, still not working. I got “No content was found”

    Here is my template code :

    [if machines]
    	{@type_machine]
    	[each machines]
    	<li>{@ID} - {@post_title}</li>
    	[/each]
    [/if]
    • This reply was modified 3 years ago by JLBA.
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @jltest

    Is machines your Pod name or the relationship field name?
    You should use the relationship field name.

    Maybe its a good idea to view our introduction video to get a better understanding of how this works!
    https://docs.pods.io/videos/grow-beyond-posts-pages-introduction-pods-framework/

    Cheers, Jory

    Plugin Author Jory Hogeveen

    (@keraweb)

    Closing due to no reply, feel free to reopen if you still need help!

    Cheers, Jory

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Displaying categories in list’ is closed to new replies.