Advise Guest to login to see Attachments

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

Previous topic - Next topic

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: