Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Use of shortcodes for catalogue entries?

Started by ian russell 9 years ago · 2 replies · 524 views
9 years ago

Would it be practical to use shortcodes to insert data from a (hidden) catalogue page?

Sections from other pages

You can even retrieve a section from another page utilizing the shortcodes as they are stored in the page's contentMeta with this syntax:

<div id="entry-x">{{ page.find('/my/custom/page').contentMeta.shortcodeMeta.shortcode.section.entry-x }}</div>

We have about 200 product groups. Each would represent a section of the catalogue. The catalogue could split into 5-20 pages if necessary.

We are not talking about e-commerce. An advantage of shortcodes over structured database records would be the each section could have its own content and layout.

Are shortcodes the way to go or is there a better method? In other words would performance limit the number of sections in the catalogue page?

Thank you.

9 years ago

Shortcodes are really a way to wrap functionality up and then allow quick access to output that functionality. I don't think they really are the solution you are looking for. It might be best to store your catalog in a structured format like json and then simply access that json data via a plugin.

In fact this is what the flex-directory plugin is doing, so you might want to check that out: https://github.com/trilbymedia/grav-plugin-flex-directory

9 years ago

Thank you for the tip. Json is probably the way to go.

As it happens I had unstructured data in mind. Each supplier goes to some trouble to set out the same sort of data in different ways. The idea was to enclose each group of records with section tags.

I'll have to look at their data and see if it maps to a json structure, or structures one per major supplier.

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 55 13 hours ago
Support · by Anna, 3 days ago
2 60 16 hours ago
Support · by Justin Young, 16 hours ago
1 31 16 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 58 5 days ago