1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

[SOLVED] display image if exists in fileupload element otherwise display image from a second element

Discussion in 'Community' started by tikimultimedia, Jan 11, 2019.

  1. tikimultimedia

    tikimultimedia New Member

    Level: Community
    I am looking for a way to have a file upload element display its own element but if no image has been uploaded then display image from another upload file element.

    It is basically only going needs to show up on the list page (not in details) so I guess I could have a totally separate image element that checks the first upload file element and if to doesn't exist it pulls the URL from the second upload file element?

    Both upload file elements will be in the same entry and there are no joins or anything complicated like that. No matter what there is always an image in the second file upload field.

    The other thing I thought about doing is somehow rewriting the the default image option so that it is dynamic according to plan but perhaps this would be more complicated?

    Thanks in advanced.
  2. tikimultimedia

    tikimultimedia New Member

    Level: Community
    Solution if anybody has a similar need (may vary slightly depending on styling preferences). In my case I needed to render separate divs.

    Using a custom template, in "default_row.php", add the following code:


    if (empty(@$this->_row->data->list___your_element_raw)) {
        echo '<div>' . @$this->_row->data->list___your_other_element . '</div>';
    } else {
        echo '<div>' . @$this->_row->data->list___your_element_raw . '</div>';
    Last edited: Jan 29, 2019

Share This Page