This is going to be a short post. Magic Tags are very awesome, but on the Pods CMS documentation failed to mention something very simple yet useful. Before anything, here’s a quick run down of what Magic Tags are…
Software Note: Pods CMS 1.7.3 / WP 2.8.4
Documentation: http://pods.uproot.us/codex/magic_tags
What are Magic Tags
From Pods CMS’ documentation: Magic Tags are used exclusively within Pod templates to dynamically pull in column values.
Usage: {@column_name} / {@column_name,display_helper}
In addition to the documentation: {@column_name.another_column_name}
The above method allow you access a different Pod’s columns when it is a PICK column inside a pod.
Let’s say you have to two pods. The Person pod, and Country pod. The Person pod has a PICK column of the Country pod to identify the nationality of that person, and you want to list all the people as: Person’s Name, Country (where you want to access by: http://domain.com/person). So inside the Pod Templates you would have something like this to show:
<p>{@name}, {@country}</p>The above displays something like below on the Person list page (http://domain.com/person):
Mon Lu, United States John Smith, Canada Ken Yamamoto, Japan
Now you want to get a bit sophisticated that you want to link the person’s name to its own detail page, and the country is linked to its own page listing all the people from that country or something like that. Not only that, you want to link the page using its own slugs/permalinks like this: http://domain.com/person/mon_lu and http://domain.com/country/usa – assuming you have a column named slug in the Person pod, and or abbrv in the Country pod. Before I figured this out, I used a Display Helper to grab the abbrv from the Country pod. But the easier way is the following, assuming this is still http://domain.com/person listing all the people where the Country pod is a PICK column inside the Person pod:
<p><a href="/person/{@slug}">{@name}</a><a href="/country/{@country.abbrv}">{@country}</a></p>Simple enough, yeah?
Related Posts
No related posts.
No Responses to “Pods CMS: Magic Tag”