XF 1.5 Correct conditional

AndreaMarucci

Well-known member
Hello, I've seen this Brogan's post

1. How can I show content just to logged in members and hide it from guests?
<xen:if is="{$visitor.user_id}">
This content will show to logged in members
</xen:if>


I've this template here
Code:
<xen:require css="imageveu_block.css" />

<div id="kog_gallery_title">
    {xen:phrase from_the_kog_gallery}
</div>

<div class="imagevue">
    <xen:foreach loop="$galleryItems" key="$key" value="$galleryItem">
        <a href="http://gallery.kog.it/{$galleryItem.canonical_file_path}">
            <div class="img_container">
                <img class="kog_cover" src="{$galleryItem.thumbnail_url}">
                <div class="album_title">
                    {$galleryItem.album_title}
                </div>
                <div class="album_date">
                    {$galleryItem.album_date}
                </div>
            </div>
        </a>
    </xen:foreach>

</div>

and I want it to be displayed only to registered members so I've modified it accordingly
Code:
<xen:require css="imageveu_block.css" />

<xen:if is="{$visitor.user_id}">

<div id="kog_gallery_title">
    {xen:phrase from_the_kog_gallery}
</div>

<div class="imagevue">
    <xen:foreach loop="$galleryItems" key="$key" value="$galleryItem">
        <a href="http://gallery.kog.it/{$galleryItem.canonical_file_path}">
            <div class="img_container">
                <img class="kog_cover" src="{$galleryItem.thumbnail_url}">
                <div class="album_title">
                    {$galleryItem.album_title}
                </div>
                <div class="album_date">
                    {$galleryItem.album_date}
                </div>
            </div>
        </a>
    </xen:foreach>

</div>

</xen:if>

but this hide the block to everyone.

Basically I'd like to display this block only to the members that are in a specific user group (id=12) so I've used this

4. How can I show content to a specific user group?
<xen:if is="{xen:helper ismemberof, $visitor, 12}">
This content will show to members of user group x
</xen:if>

but I've got a lot of error and no display at all of the block.

I'm using XF 1.5.3

Thanks for your help...
 
This was the error in last case

Template Errors: imageveu_block
  1. Argument 1 passed to XenForo_Template_Helper_Core::helperIsMemberOf() must be of the type array, null given in /home/kogit/forum/library/XenForo/Template/Helper/Core.php, line 1344
  2. Argument 1 passed to XenForo_Model_User::isMemberOfUserGroup() must be of the type array, null given, called in /home/kogit/forum/library/XenForo/Template/Helper/Core.php on line 1352 and defined in /home/kogit/forum/library/XenForo/Model/User.php, line 1707
 
Is that a custom template?

Which core template are you including it in?

Just wrap the include in the visitor conditional statement and it should work.
 
It's a custom template and I'm not including any core template in it, if I've understood correctly what you're meaning. It's part of an addon developed for me that show some random pictures in the forum. I'd just like to show these pictures to the registered members.
 
It's a custom template and I'm not including any core template in it, if I've understood correctly what you're meaning. It's part of an addon developed for me that show some random pictures in the forum.
Which page on the forum are you showing the images?

Is it a completely custom route or is it part of a default page which you are including your custom template into?

If the former, you will need to develop the add-on correctly to pass the $visitor record.

If the latter, wrap the include in the conditional statement.
 
This was the error in last case

Template Errors: imageveu_block
  1. Argument 1 passed to XenForo_Template_Helper_Core::helperIsMemberOf() must be of the type array, null given in /home/kogit/forum/library/XenForo/Template/Helper/Core.php, line 1344
  2. Argument 1 passed to XenForo_Model_User::isMemberOfUserGroup() must be of the type array, null given, called in /home/kogit/forum/library/XenForo/Template/Helper/Core.php on line 1352 and defined in /home/kogit/forum/library/XenForo/Model/User.php, line 1707

This error messages indicates to me that $visitor does not exist. Can you please tell us in more details what you are trying to do?
 
Brogan I'm not able to tell you what you're asking :-(

if you look here http://forum.kog.it you'll see a block with 4 images that are randomly taken from my Imagevuex gallery. I'd like to show this block only to the members of a specific usergroup or, if it's not possible, only to the registered users.
 
It's a custom addon developed for me from a freelance I've found here on the XF Forum, @alexD so I'm not able to tell you what exactly does. I've tagged him here so maybe he'll answer to your question...
 
I suspect it's using a template modification.
In which case you can wrap that in the conditional statement.

However, you should really contact the developer for support with a custom add-on such as this.
 
Back
Top Bottom