简体   繁体   中英

PyroCMS: module, plugin, or widget?

I'm new to PyroCMS and struggling to figure out how to implement something.

Say I have a list of products I want to display. Each item in the list shows a photo of the product, a description, and its price. This listing of products can be used on the homepage (eg displaying a few products), or in the search results (eg a SERP), or a browse page, etc.

I should be able to create one "thing" that has all the markup needed for this listing, along with it being able to accept parameters (eg only get the top 5 items to display on the homepage). Problem is I don't know what this "thing" should be: module, plugin, or widget?

Suggestions?

Do you need to be able to manage the products via control panel? Then you at least need to start by creating a module. From the glossary :

...All custom code that requires an interface and extra CSS or JavaScript files should be written as a Module, not a Widget.

From there, the line gets a bit blurry:

Similar to Widgets, Plugins are self-contained logic that can be embedded into content or theme layouts, but instead of having a graphical element these are handled entirely through Tag syntax.

Widgets - Small chunks of self-contained logic and HTML that can be installed in the admin interface. They can be assigned to specific Widget Areas and ordered visually.

If I remember correctly, both plugins and widgets accept parameters. The main difference is that widgets get assigned to specific template areas, while plugins can be embedded in content anywhere you want with {tags}. Since this is going to be embedded in the content of only certain pages, I'd go with a plugin.

Reading you requirements carefully the answer is that you need a module.
Look, I am a beginner in PyroCMS too, but after 2 months using it I have build modules, plugins, and widgets and I can tell you that for the importance that your code have (show listing of products, search functionality, maybe upload images?) the appropriate is a module .

You will have the same functionality that gives you a widget or a plugin but a module is the whole thing: use external libraries, includes js/css in the HEAD , add admin functionality, build modular plugins, use the settings table and the Settings tab in the backend to easily set and access variables from the entire application.

Besides if it is your first experience using PyroCMS a module will give you a more wider view of the entire CMS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM