lucid-fox / social-magick

An Open Graph Image generator plugin for Joomla 3 and 4
GNU General Public License v3.0
15 stars 1 forks source link

Different templates for child items #2

Closed nikosdion closed 3 years ago

nikosdion commented 3 years ago

Use case: the category uses template A but its articles use template B. Things get even more complicated when you have nested categories.

Solving this requires adding Social Magick options to a. Categories and b. Articles

Category options need to have TWO separate areas i. the category itself and ii. its Articles.

Each of these areas needs to have an additional switch: Override menu item and parent category options default No. When it's set to Yes and only then do we show the rest of the options.

Articles have obviously one set of options. There is one additional switch: Override menu item and parent category options default No. When it's set to Yes and only then do we show the rest of the options.

As far as the plugin itself goes, we need to check if we are displaying a category or an article.

If displaying a category, check its options. If the category-specific Social Magick options override is enabled use these options instead of the menu item's. If it's disabled look in its parent category until you EITHER find overrides OR reach the root node. In the latter case we use the menu item options.

If displaying an article we need to do two things. First, check if the article has the override switch enabled. If so, use its options and call it a day. Second, if and only if the article's override switch is disabled, check if the articles-specific Social Magick options override is enabled in its category. If so, use these. Otherwise walk through the parent categories until an override is found or you reach the root note. In the latter case we use the menu item options.