Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • IPS Customization.

    While building this website I have learned a lot about how to customiza different aspects of the IPS products. I see a lot of people struggling to get started with IPS and this section is my attempt to gather what I have learned so others can benefit as well.

    To me nothing is more important than to share knowledge and help others. This section contain my findings and the things I have learned, but I still have much more to learn as well. Together we can learn and evolve the ways we customize the IPS products and while doing that there are no stupid questions. In the forum you can ask any question and we will try our best to answer them.

    Go to the IPS Forum ->
  • Show cusom field with condition

    Jimi Wikman

    If you want to show a custom field inside the category template, then you use this code:

    {$record->customFieldDisplayByKey('NAME-OF-FIELD', 'display')|raw}


    If you want to only show this when there is a value in the field, then you wrap it in a condition like this:

    {{if $record->customFieldDisplayByKey('NAME-OF-FIELD')}}
    {$record->customFieldDisplayByKey('NAME-OF-FIELD', 'display')|raw}


    Template Syntax (from IPS Documentation)

    Any field you have created can be used within your database templates. This can be done using the following code

    {$record->customFieldDisplayByKey('your_template_key', 'viewtype')|raw}

    The template key parameter would be whatever you have entered in the 'Template Key' field, in the display tab of your custom field. 

    The view type parameter is what you would use in order to specify what format you are using, which would depend on which of the options from your display tab in your custom field you wish to show. The view types that can be used are as follows

    • listing - This will show the value as per any listing badge preferences as set up on your custom field. This is usually used within a record list.
    • display/display_top/display_bottom - Each of these show the value as per any display value set up in your custom field. Display on its own will just show the format, however you can use display top and bottom to display based on which of these items is selected within that field for the display section.
    • thumbs - returns an array of \IPS\File objects . Returned only with image types, where thumbnail creation is selected.
    • upload- returns an array of \IPS\File objects . Returned only with upload field type.
    • raw - this will show the value as store in the database, unless there are muliple upload (returned as an array of URLs) or they are a Reciprocal field type (returned as an array of record objects)
    • processed - this will show the raw value as specified above, however is also passed through the form helper

    Adding |raw will mean that the value will not be escaped. For some items which specifically contain URLs this may be desirable. For example returning a thumbnail, or a youtube item. However if using for items such as plain text, please be aware that you are allowing raw unescaped text to be added to the page.


    User Feedback

    Recommended Comments

    There are no comments to display.

    Please sign in to comment

    You will be able to leave a comment after signing in

    Sign In Now

  • Create New...