.. include:: _include.rst .. highlight:: bbcode .. _repo_advanced: ############################ Repo Advanced ############################ ******************* Categories and Tags ******************* Like you know it from standard posts, you can use categories and tags with Repo items. In this example, the Jedi Interceptor is settled in the LEGO category **"Star Wars"** and I tagged it with **"spaceship"** and **"yellow"**. .. image:: _static/repo_edit_cat_tag.png :height: 720px :width: 815px :scale: 100% :alt: ASA 2 Repo categories and tags Now you can use |asa2|'s shortcode :ref:`shortcodes_asa2_smart_collection` to dynamically embed items on your pages based on categories and tags. For example, if you want to embed three items from the category "Star Wars" tagged with "spaceship", you could use the following shortcode: .. code:: [asa2_smart_collection cat_slug="starwars" tag="spaceship" limit="3"] You want to show 10 "yellow" tagged items in a random order? Use this shortcode: .. code:: [asa2_smart_collection tag="yellow" limit="10" orderby="random"] ********************************* Shortcode [asa2_smart_collection] ********************************* The shortcode :ref:`shortcodes_asa2_smart_collection` is one of the **most powerful features** of |asa2|. With it you can create **dynamic queries** to your |repo| with filters for many relevant product properties. For example, to display only Star Wars spaceships having a better average rating than 4, use this shortcode: .. code:: [asa2_smart_collection cat_slug="starwars" tag="spaceship" rating_gt="4"] You can also add a price filter. This example would only display Repo items with a main price lower than 100. .. code:: [asa2_smart_collection cat_slug="starwars" tag="spaceship" rating_gt="4" main_price_lt="100"] Check the shortcode page :ref:`shortcodes_asa2_smart_collection` for a detailed list of all available options. .. _repo_adv_custom_fields: ************* Custom Fields ************* Another powerful feature is the use of Custom Fields with your Repo items. On https://asa2-demo.de/custom-fields/ I have setup Custom Fields for my personal rating and my recommendation on a product. The easiest way to create these, is with the plugin `Advanced Custom Fields `_ (ACF). When you setup a new field group for Repo items in ACF, just set the rule to "Post Type - is equal to - asa_repo": .. image:: _static/repo_acf_location.png :height: 217px :width: 868px :scale: 100% :alt: ASA 2 Repo ACF location Then I setup the rating field with field type "Number", field name "my_rating", minimum value "1" and maximum value "10", like shown in this screenshot: .. image:: _static/repo_acf_1.png :height: 738px :width: 865px :scale: 100% :alt: ASA 2 Repo ACF field The second field "recommendation" I setup with field type "Radio Button" and three choices you can see in this screenshot: .. image:: _static/repo_acf_2.png :height: 607px :width: 575px :scale: 100% :alt: ASA 2 Repo ACF field When I enter the edit page of a Repo item it looks like this: .. image:: _static/repo_acf_3.png :height: 776px :width: 880px :scale: 100% :alt: ASA 2 Repo ACF field I can enter a personal rating from 1 to 10 and check the radion button "Yes" if I would recommend the product. This data can then be used in |asa2| templates. In your templates you can use all custom fields with this special placeholder: .. code:: {{ repo_custom_field_* }} You just have to replace the "*" with the name of your custom field, like for this example to retrieve the value of custom field "**my_rating**": .. code:: {{ repo_custom_field_my_rating }} .. note:: Learn more about all available |asa2| :ref:`placeholders`. Now, to display my personal rating only if I have set a value, I use this **template code**: .. highlight:: smarty .. code:: {% if repo_custom_field_my_rating is not empty %}

My personal rating: {{ repo_custom_field_my_rating }}

{% endif %} And to show if I recommend a product: .. code:: {% if repo_custom_field_recommendation == "yes" %}

I recommend this product!

{% endif %} .. note:: Learn more about |asa2|'s :ref:`template_syntax`. Of course I could display anything instead of just text, for instance load an image with my custom rating stars or a recommendation badge etc. This is just a demonstration of what is possible with custom fields on Repo items and |asa2|'s conditional template syntax.