XF 2.2 If there is no image, use the default image?

webtiryaki

Active member
Hello, I'm looking for a solution on this
If there is no image, use the default image

PHP:
<xf:if is="?">
                      <img src="{$xf.options.boardUrl}/styles/uls/kat/{$node.node_id}.jpg">
                       <xf:else />
                     <img src="{$xf.options.boardUrl}/styles/uls/kat/default.jpg">
                  </xf:if>

resim1.webp
 
Hello, I'm looking for a solution on this
If there is no image, use the default image

PHP:
<xf:if is="?">
                      <img src="{$xf.options.boardUrl}/styles/uls/kat/{$node.node_id}.jpg">
                       <xf:else />
                     <img src="{$xf.options.boardUrl}/styles/uls/kat/default.jpg">
                  </xf:if>

View attachment 285438

Hello, does anyone have any ideas about this?
<xf:if is="?"> how do I define this code

In normal PHP, this is very easy, while xenforo does not?

for example
PHP
PHP:
global $settings;
if (file_exists($settings['theme_dir'] . '/images/kategori/' . $board['id'] . '.png'))
    echo '<div class="node-img" style="background-image: url(\'' . $settings['images_url'] . '/kategori/' . $board['id'] . '.png\');"></div>';
else
    echo '<div class="node-img" style="background-image: url(\'' . $settings['images_url'] . '/kategori/default.jpg\');"></div>';
 
Where are the images being defined exactly?
Hello Russ
code node_list_forum

PHP:
<div class="node node--id{$node.node_id} node--depth{$depth} node--forum {{ $extras.hasNew ? 'node--unread' : 'node--read' }}">
        <div class="node-body">
            <div class="cat-media">               
                <div class="cat-media-inner">
                        <xf:if is="$node.node_id == 2">
                      <img src="{$xf.options.boardUrl}/styles/uls/kat/{$node.node_id}.jpg">
                       <xf:else />
                     <img src="{$xf.options.boardUrl}/styles/uls/kat/default.jpg">
                  </xf:if>
                </div>               
                <div class="kcat-header">
                    <!-- Cat title -->
                    <h3 class="cat-title">
                    <span class="node-iconn" aria-hidden="true">
                    <xf:fa icon="{{ $node.Data.TypeHandler.getTypeIconClass() ?: 'fa-comments' }}" />
                    </span>
                    <a href="{{ link('forums', $node) }}" data-xf-init="{{ $descriptionDisplay == 'tooltip' ? 'element-tooltip' : '' }}" data-shortcut="node-description">{$node.title}</a>
                   </h3>
                    <!-- // Cat title -->
                </div>
            </div>
                <span class="node-icon" aria-hidden="true">
                <xf:fa icon="{{ $node.Data.TypeHandler.getTypeIconClass() ?: 'fa-comments' }}" />
            </span>
            <div class="node-main js-nodeMain">
                <xf:if is="$chooseName">
                    <xf:checkbox standalone="true">
                        <xf:option labelclass="u-pullRight" class="js-chooseItem" name="{$chooseName}[]" value="{$node.node_id}" />
                    </xf:checkbox>
                </xf:if>

                <xf:set var="$descriptionDisplay" value="{{ property('nodeListDescriptionDisplay') }}" />
                <h3 class="node-title">
                    <a href="{{ link('forums', $node) }}" data-xf-init="{{ $descriptionDisplay == 'tooltip' ? 'element-tooltip' : '' }}" data-shortcut="node-description">{$node.title}</a>
                </h3>
                <xf:if is="$descriptionDisplay != 'none' && $node.description">
                    <div class="node-description {{ $descriptionDisplay == 'tooltip' ? 'node-description--tooltip js-nodeDescTooltip' : '' }}">{$node.description|raw}</div>
                </xf:if>
 
So your code works as far as I can tell?

You can add multiple checks like this:

Code:
            <xf:if is="$node.node_id == 2">
                NODE2
                <xf:elseif is="$node.node_id == 3" />
                NODE3             
                <xf:else />
                NODE 4
            </xf:if>


1683301283493.webp
 
Back
Top Bottom