I've set up a layout override which is working, however I'd like to output the VALUE of a specific custom field at a specific location (namely as a class so that I can differently style the "product-item" blocks.

What code should I use to achieve this?

    Hi arcascomputing

    Kindly share the credentials of your site and tell me which kind of content you're using to filter.

    And tell me the layout + field + location you want to show, I will take a look if it can be done.

      saguaros

      Thanks for this, have updated the fields now for you with the site info.

      I'm filtering K2 content for a list of awards and one of the custom fields is the award status so I was wanting to be able to add that status in as a class name into the product item wrapper in my custom layout which would therefore allow me to style the wrappers differently based on status (ie a colour).

      The layout override is in the active template's html folder under layouts/megafilter/k2/awards, the field is called "Status" (alias also "Status") and its ID is 7. I'd likely add the value like this:

      <div class=" item product product-item #insertstatusfieldvaluehere# ">
        7 days later

        Hi there, can you provide me with an update on this, it's been over a week since the initial request, all i need to know is what code to use to output the value of a specific field at a specific location in the template?

          arcascomputing

          You can use this syntax: {attr.ct11.value} into the file: /plugins/jamegafilter/k2/layouts/default/product-item.php

          11 here is the ID of custom field you want to add.

          Thanks for this but that doesn't work for me I'm afraid, no value is being output. I tried putting the code in different places (for example after the {@info:data} part) in case that mattered but basically wherever I paste it makes no difference, nothing is output.

          Any suggestions?

          Apologies, just realised that the ID of the field in your example was different than the one I'd stated, very silly of me to not even check that! Implemented now and I'm getting the number of the option rather than the value but that doesn't really matter on this occasion as I can still target the CSS now.

          (Though it might be handy to know how to output a select list's text value rather than option number)

            Write a Reply...
            You need to Login to view replies.