Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Topic started by: aw06 on February 10, 2011, 10:23:28 AM

Title: Advise Guest to login to see Attachments
Post by: aw06 on February 10, 2011, 10:23:28 AM
On SMF 1.1.12 When attachments are disabled from guest viewing, ... is it possible to have a note so they can know an attachment is present and they need to login to see it...
Title: Re: Advise Guest to login to see Attachments
Post by: Illori on February 10, 2011, 10:27:16 AM
you can check the mod site and if you dont see a mod to do what you want you can post in the proper board to request one.
Title: Re: Advise Guest to login to see Attachments
Post by: kat on February 10, 2011, 01:05:20 PM
I assume you mean "Register", coz guests can't log in...

I can't find a mod that does exactly what you want. But, what about this one?

http://custom.simplemachines.org/mods/index.php?mod=1449
Title: Re: Advise Guest to login to see Attachments
Post by: aw06 on February 10, 2011, 01:21:37 PM
Quote from: K@ on February 10, 2011, 01:05:20 PM
I assume you mean "Register", coz guests can't log in...

I can't find a mod that does exactly what you want. But, what about this one?

http://custom.simplemachines.org/mods/index.php?mod=1449

Well technically register yes .. but a guest can login if they have an account  :) Many people will view as guest and only log in when they need to post etc...

Naw that mod is totally diff..
Title: Re: Advise Guest to login to see Attachments
Post by: kat on February 10, 2011, 01:26:25 PM
Maybe a post in "Mod Requests", then?
Title: Re: Advise Guest to login to see Attachments
Post by: Matthew K. on February 10, 2011, 01:31:16 PM
It'd be fairly easy to do with a template tweak. Something like... if ($context['user']['is_logged']) {} around where the attachments are outputted. You'd also probably want to add an else that would show a link to $scripturl. '?action=register and a similar one for logging in.
Title: Re: Advise Guest to login to see Attachments
Post by: aw06 on February 10, 2011, 01:31:20 PM
Quote from: K@ on February 10, 2011, 01:26:25 PM
Maybe a post in "Mod Requests", then?

If possible can you move this ?? so i don't have to re-post ?
Title: Re: Advise Guest to login to see Attachments
Post by: aw06 on February 10, 2011, 01:32:59 PM
Quote from: Labradoodle-360 on February 10, 2011, 01:31:16 PM
It'd be fairly easy to do with a template tweak. Something like... if ($context['user']['is_logged']) {} around where the attachments are outputted. You'd also probably want to add an else that would show a link to $scripturl. '?action=register and a similar one for logging in.

Yup, more i less what i was thinking .. a guest would see in place of the actual attachment..

Attachment Available - Please Register or Login to View
Title: Re: Advise Guest to login to see Attachments
Post by: Matthew K. on February 10, 2011, 01:39:06 PM
I'll go ahead and write up the mod for you. Give me 5 minutes.
Title: Re: Advise Guest to login to see Attachments
Post by: aw06 on February 10, 2011, 01:48:09 PM
Quote from: Labradoodle-360 on February 10, 2011, 01:39:06 PM
I'll go ahead and write up the mod for you. Give me 5 minutes.

OK, my site if currently down .. and wont be back up for a few hours .. as well as i will be installing a few attachment mods ... so if possible you can hold off until i am back up and running, as i am not sure if the mods will affect the mod you would write .. buts thanks allot for your effort and offer..
Title: Re: Advise Guest to login to see Attachments
Post by: Matthew K. on February 10, 2011, 01:52:01 PM
Hmmm, I did a fresh install of 1.1.12, and I can't see attachments when I'm a guest anyways?
Title: Re: Advise Guest to login to see Attachments
Post by: aw06 on February 10, 2011, 02:04:35 PM
Quote from: Labradoodle-360 on February 10, 2011, 01:52:01 PM
Hmmm, I did a fresh install of 1.1.12, and I can't see attachments when I'm a guest anyways?

Check permissions ... Perhaps by default the option for guest to view attachments is set to off ..
Title: Re: Advise Guest to login to see Attachments
Post by: Matthew K. on February 10, 2011, 02:13:00 PM
Here you are :)

http://prntscr.com/1jt2m
Title: Re: Advise Guest to login to see Attachments
Post by: aw06 on February 10, 2011, 02:18:23 PM
Quote from: Labradoodle-360 on February 10, 2011, 02:13:00 PM
Here you are :)

http://prntscr.com/1jt2m

Nice that was really quick  :P

Question: Will it show that message for each attachment ? or it will just show one message ? also can you show me what files are modified so i can see if it will conflict with other attachment mods I will be installing ...
Title: Re: Advise Guest to login to see Attachments
Post by: Matthew K. on February 10, 2011, 02:23:21 PM
It shows one message despite the count of attachments. It shouldn't have any conflicts. It's fairly straight forward.

It makes two modifications to Display.template.php.

The 1st:
Code (Find) Select
if (!empty($message['attachment']))
Code (Replace) Select
if (!empty($message['attachment']) && $context['user']['is_logged'])
The 2nd:
Code (Find) Select
echo '
</td>
</tr><tr>
<td valign="bottom" class="smalltext" id="modified_', $message['id'], '">';

Code (Add Before) Select
// Labradoodle-360; Hide Attachments from Guests
elseif ($context['user']['is_guest'] && !empty($message['attachment']))
echo '<hr width="100%" size="1" class="hrcolor" />
<div style="overflow: auto; width: 100%;">
<strong>', $txt['lab360_attachments_avail'], '</strong>
</div>';
// End Labradoodle-360; Hide Attachments from Guests

Then it makes one modification to Modifications.english.php
Code (Add Before End) Select
$txt['lab360_attachments_avail'] = 'Attachment(s) Available - <a href="'. $scripturl. '?action=login" target="_self">Login</a> or <a href="'. $scripturl. '?action=register" target="_self">Register</a>';

Donations are appreciated as always :)

You can also take this mod over and submit it to the SMF Mod Site if you would like, as I have no intentions of submitting it.

Best Regards,
Labradoodle-360
Title: Re: Advise Guest to login to see Attachments
Post by: aw06 on February 10, 2011, 02:26:26 PM
OK kool, will let you know how it goes when i install and start to use it ... thanks again
Title: Re: Advise Guest to login to see Attachments
Post by: Matthew K. on February 10, 2011, 02:27:04 PM
Not a problem. Feel free to mark this topic as resolved once you are confident the results are as you are expecting.
Title: Re: Advise Guest to login to see Attachments
Post by: aw06 on February 10, 2011, 02:28:21 PM
Quote from: Labradoodle-360 on February 10, 2011, 02:27:04 PM
Not a problem. Feel free to mark this topic as resolved once you are confident the results are as you are expecting.

Sure , will do ...

Would this be allowed .. ??

Change
Attachment(s) Available

To
Image(s) Available
Title: Re: Advise Guest to login to see Attachments
Post by: aw06 on February 18, 2011, 11:09:48 PM
Installed and now testing .. strange though ,, it's not showing up .. i did the manual edits.

guest permission is set to view attachments..
Title: Re: Advise Guest to login to see Attachments
Post by: aw06 on February 18, 2011, 11:16:51 PM
Quote from: Labradoodle-360 on February 10, 2011, 02:23:21 PM
It shows one message despite the count of attachments. It shouldn't have any conflicts. It's fairly straight forward.

It makes two modifications to Display.template.php.

The 1st:
Code (Find) Select
if (!empty($message['attachment']))
Code (Replace) Select
if (!empty($message['attachment']) && $context['user']['is_logged'])


Should'nt that be
if (!empty($message['attachment']) && $context['user']['is_guest'])

?
Title: Re: Advise Guest to login to see Attachments
Post by: aw06 on February 18, 2011, 11:19:57 PM
OK, that didn't work lol
Title: Re: Advise Guest to login to see Attachments
Post by: Matthew K. on February 19, 2011, 09:21:31 PM
No, it should be && $context['user']['is_logged']. If you look at the code inside the if statement, it's to SHOW attachments...and you only want them to show if there ARE attachments, and it's a member. Then, we add an elseif statement below that shows them a message if there ARE attachments, but they're a guest.
Quote from: aw06 on February 18, 2011, 11:16:51 PM
Quote from: Labradoodle-360 on February 10, 2011, 02:23:21 PM
It shows one message despite the count of attachments. It shouldn't have any conflicts. It's fairly straight forward.

It makes two modifications to Display.template.php.

The 1st:
Code (Find) Select
if (!empty($message['attachment']))
Code (Replace) Select
if (!empty($message['attachment']) && $context['user']['is_logged'])


Should'nt that be
if (!empty($message['attachment']) && $context['user']['is_guest'])

?
Title: Re: Advise Guest to login to see Attachments
Post by: Matthew K. on February 19, 2011, 09:22:06 PM
What about it didn't work?
Quote from: aw06 on February 18, 2011, 11:19:57 PM
OK, that didn't work lol
Title: Re: Advise Guest to login to see Attachments
Post by: aw06 on February 19, 2011, 09:41:01 PM
Not seeing the message ... attachments just disappear
Title: Re: Advise Guest to login to see Attachments
Post by: Matthew K. on February 19, 2011, 09:44:58 PM
What edits specifically did you complete?
Title: Re: Advise Guest to login to see Attachments
Post by: aw06 on February 19, 2011, 09:49:30 PM
Quote from: Labradoodle-360 on February 19, 2011, 09:44:58 PM
What edits specifically did you complete?

Those listed ... did them exactly.

Quote from: Labradoodle-360 on February 10, 2011, 02:23:21 PM
It shows one message despite the count of attachments. It shouldn't have any conflicts. It's fairly straight forward.

It makes two modifications to Display.template.php.

The 1st:
Code (Find) Select
if (!empty($message['attachment']))
Code (Replace) Select
if (!empty($message['attachment']) && $context['user']['is_logged'])
The 2nd:
Code (Find) Select
echo '
</td>
</tr><tr>
<td valign="bottom" class="smalltext" id="modified_', $message['id'], '">';

Code (Add Before) Select
// Labradoodle-360; Hide Attachments from Guests
elseif ($context['user']['is_guest'] && !empty($message['attachment']))
echo '<hr width="100%" size="1" class="hrcolor" />
<div style="overflow: auto; width: 100%;">
<strong>', $txt['lab360_attachments_avail'], '</strong>
</div>';
// End Labradoodle-360; Hide Attachments from Guests

Then it makes one modification to Modifications.english.php
Code (Add Before End) Select
$txt['lab360_attachments_avail'] = 'Attachment(s) Available - <a href="'. $scripturl. '?action=login" target="_self">Login</a> or <a href="'. $scripturl. '?action=register" target="_self">Register</a>';

Donations are appreciated as always :)

You can also take this mod over and submit it to the SMF Mod Site if you would like, as I have no intentions of submitting it.

Best Regards,
Labradoodle-360
Title: Re: Advise Guest to login to see Attachments
Post by: Matthew K. on February 19, 2011, 09:54:15 PM
Try to figure out if the conditions are being met or not...you can simply use die(); after the if statement, and after the elseif, and see which one is returned.

Furthermore, are there any errors in the error log?
Title: Re: Advise Guest to login to see Attachments
Post by: aw06 on February 19, 2011, 10:10:33 PM
Quote from: Labradoodle-360 on February 19, 2011, 09:54:15 PM
Try to figure out if the conditions are being met or not...you can simply use die(); after the if statement, and after the elseif, and see which one is returned.

Furthermore, are there any errors in the error log?

Negative .. no errors
Title: Re: Advise Guest to login to see Attachments
Post by: Matthew K. on February 19, 2011, 10:47:23 PM
Quote from: Labradoodle-360 on February 19, 2011, 09:54:15 PM
Try to figure out if the conditions are being met or not...you can simply use die(); after the if statement, and after the elseif, and see which one is returned.
Title: Re: Advise Guest to login to see Attachments
Post by: aw06 on February 19, 2011, 10:59:10 PM
as in ..

if (!empty($message['attachment']) && $context['user']['is_logged']) die();

and

elseif ($context['user']['is_guest'] && !empty($message['attachment'])) die();

??
Title: Re: Advise Guest to login to see Attachments
Post by: Matthew K. on February 19, 2011, 11:21:11 PM
die(); would be on it's own line, but yeah. In addition, you'll probably want to put brackets around the if, and elseif statements.

Example
if (this)
{
// Do this
}
elseif (this)
{
// Do this
}
Title: Re: Advise Guest to login to see Attachments
Post by: aw06 on February 20, 2011, 07:19:55 AM
Quote from: Labradoodle-360 on February 19, 2011, 11:21:11 PM
die(); would be on it's own line, but yeah. In addition, you'll probably want to put brackets around the if, and elseif statements.

Example
if (this)
{
// Do this
}
elseif (this)
{
// Do this
}


OK kool, thing is i am not a ninja coder like you guys  :P so i really am not 100% certain how the do the coding
Title: Re: Advise Guest to login to see Attachments
Post by: Matthew K. on February 20, 2011, 11:54:42 AM
It's not a problem
Title: Re: Advise Guest to login to see Attachments
Post by: ziskar364 on April 03, 2020, 04:48:31 PM
I know I am digging in graves but is there any similar mod for SMF 2.0.17?

I have recently started allowing specific sections of the forum to be publicly visible but their attachments are hidden, so I would like to show a message to guests that will advise registering in order to view attachments and gain full access to the forum topics.

I would really appreciate any help!