XF 2.2 Attachmens and guests, avatars and guests

Robert9

Well-known member
I dont want to hide anything, i want to replace.

For this i have to find the perfekt place, where attachments, inserted attach and attach full are prepared.
Probably i will find this in a file attachment.php ...

The same, i hope, will be possible for the avatars. Better would be here just to use the „C“har.

Then guests will see everywhere in the forum only these one or two dummy pictures with a text like „please login!“.

I hope this is possible with less code. But i am wondering, that nobody has done this before.
May someone know something about this problem and how to solve?
 

Robert9

Well-known member
No. Because then i have to change 1 million places in all templates to add "if guest, dont show, else show".
I need an addon that injects the right place, where attachments / avatars are build just one time for all places where we show them.
 

kelle67

Active member
No. Because then i have to change 1 million places in all templates to add "if guest, dont show, else show".
I need an addon that injects the right place, where attachments / avatars are build just one time for all places where we show them.

Sorry but @Brogan have right. You have to change 4 or 5 templates that's all. If I not forget I will share the modification at the evening. I'm at work right now.
 

Robert9

Well-known member
Are you talking about attachments or about avatar or about both?

1. Avatar should be replaced by the "char" or a "dummy picture", there are many, many plcaes for. The check for guest or not and image or "char" needs to be done somehwere else and not in templates, i think.

2. There is an addon for attachments, but it is not functional for inserted attachments. Only for the ones not inserted.

Probably this is possible by template-mods. To make it perfect, users should decide what they want.
Then we need custom_userfields and template_mods or we have an addon for this and let XF decide at the right place what we do.
 

kelle67

Active member
Sorry to keep you waiting but it's been a very long two days.

Lets start.

The first thing you should do is to limit the rights of the guests as much as possible. With us, they don't see a gallery, they don't see the member list and they can't access member profiles.

Now to the templates:

1. The first template is the: bb_code_tag_attach. This hide all attacjments for guests.

in the first line add:
Code:
<xf:if is="$xf.visitor.user_id">

and in the last line close the tag

</xf:if>

Iff you wnt show a text or a picture put a else tag bevor you close the tag


Code:
<xf:else />
    {{ phrase('log_in_or_register_now') }}&nbsp;{{ phrase('to_view_attachments') }}

As an alternative to a phrase, you can of course also have a standard picture displayed.

Code:
<xf:else />
    <img src="path to your picture">


User:

1613803608160.png

Guest:

1613803667893.png


2. The next template is: message_macros

find:

Code:
<div class="message-avatar-wrapper">

and add again before :

Code:
<xf:if is="$xf.visitor.user_id">

close this tag again with:

Code:
</xf:if>

1613805040757.png

3. Next template is: node_list_category

find:
<div class="node-extra-icon">

and add again before :

Code:
<xf:if is="$xf.visitor.user_id">

close this tag again with:

Code:
</xf:if>

1613805526560.png


4. next template is: node_list_forum

find:
<div class="node-extra-icon">

and add again before :

Code:
<xf:if is="$xf.visitor.user_id">

close this tag again with:

Code:
</xf:if>

1613806267720.png


5. next template is: thread_list_macros, there is two places.


find:
<div class="structItem-iconContainer">

and add again before :

Code:
<xf:if is="$xf.visitor.user_id">

close this tag again with:

Code:
</xf:if>
1613806641930.png

second place:


find:
<div class="contentRow-figure">

and add again before :

Code:
<xf:if is="$xf.visitor.user_id">

close this tag again with:

Code:
</xf:if>

1613806795397.png

After the modifications it looks like this:

1613807074385.png

This is good enough for me.
If you still want to display a standard avatar, you have to enter
Code:
</xf:if>
before you start:

Code:
</xf:if>

use the following code:

Code:
<xf:else />
            <div class="contentRow-figure">
                <img src="path to your image">
            </div>

1613807792921.png

It is important or easier to give the newly inserted div the same class as the div you are hiding for guests.

In the example:
Code:
class="contentRow-figure"

after that, it looks like this:

1613808059935.png

It's a bit of work but it shouldn't take more than 30 minutes.
It's just copy and paste.

Maybe you can do it even easier in the extra.less. But I am not professional enough for that.

Still to be expanded.
 
Last edited:

Robert9

Well-known member
Thank. Very kind from you.
And to extend we can add a cutom_user_field cuf with the question to hide or not.
As long this cuf is reachable in a te,plate we can change the if, then.

If the cuf is not usable, we can extend xf_user with a new field.
 
Top