News:

Wondering if this will always be free?  See why free is better.

Main Menu

Advise Guest to login to see Attachments

Started by aw06, February 10, 2011, 10:23:28 AM

Previous topic - Next topic

aw06

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...
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Illori

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.

kat

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

aw06

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..
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

kat


Matthew K.

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.

aw06

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 ?
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

aw06

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
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Matthew K.

I'll go ahead and write up the mod for you. Give me 5 minutes.

aw06

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..
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Matthew K.

Hmmm, I did a fresh install of 1.1.12, and I can't see attachments when I'm a guest anyways?

aw06

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 ..
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth


aw06

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 ...
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Matthew K.

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

aw06

OK kool, will let you know how it goes when i install and start to use it ... thanks again
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Matthew K.

Not a problem. Feel free to mark this topic as resolved once you are confident the results are as you are expecting.

aw06

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
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

aw06

Installed and now testing .. strange though ,, it's not showing up .. i did the manual edits.

guest permission is set to view attachments..
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

aw06

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'])

?
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

aw06

:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Matthew K.

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'])

?

Matthew K.


aw06

Not seeing the message ... attachments just disappear
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Matthew K.


aw06

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
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Matthew K.

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?

aw06

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
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Matthew K.

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.

aw06

as in ..

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

and

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

??
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Matthew K.

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
}

aw06

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
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Matthew K.


ziskar364

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!

Advertisement: