vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   change attachment link (https://vborg.vbsupport.ru/showthread.php?t=252461)

Hornstar 10-22-2010 11:50 PM

change attachment link
 
Is it possible to change the link for 1 of my attachments?

For example on vb.org here is an example attachment url: https://vborg.vbsupport.ru/attachmen...3&d=1263721711

Lets say when a user clicks on that, they are taken to a different link(page), and then after they do what is on that page, it redirects them to the proper link(attachment).

I am fine with the 2nd part, but the first part of changing only the 1 attachment link has got me stumped.

I am thinking it must be possible using the attachment ID or something. any ideas?

Lynne 10-23-2010 12:16 AM

You could use the Replacement Variable Manager to change the URL

Hornstar 10-23-2010 03:42 AM

Interesting idea ^^

I'll see how it goes. I've never used or known about that feature before :)

--------------- Added [DATE]1287811065[/DATE] at [TIME]1287811065[/TIME] ---------------

Nope didn't work as the replacement variable feature has a character limit for the url :/ Any idea how to change that?

--------------- Added [DATE]1287813329[/DATE] at [TIME]1287813329[/TIME] ---------------

I finally found a link that was small enough to test this with. But it is not working for me.

What do I put in:
Search for Text (Case-Insensitive):
and
Replace with Text

If the link was www.site.com/link.html and the file www.site.com/file.zip for example.

Thanks.

Lynne 10-23-2010 02:42 PM

Are you putting in the whole url or just the file name part? I'd try:
Search for: link.html
Replace with: file.zip

Does that work?

Hornstar 10-23-2010 10:05 PM

Here is a reply from Steve over at vb.com
Quote:

That is the problem. The Replacement Variables do not replace the links to attachments. They replace specific text added to a post. So you cannot use Replacements to do what you want in this case.

In fact there is no function to do this. This requires modifying the code. We cannot officially support code modifications or forums running modified code, however you can try searching or asking for help with this over at http://www.vbulletin.org.
Back to the drawing board. Do you have any other suggestions :)

Lynne 10-23-2010 11:53 PM

Modify the template with a condition?

To find the template to modify, do this - vboptions > General Settings > Add Template Name in HTML Comments > set to Yes . Then go back to your page and view the source code and you will see the name of the template called around your part of the code. (Sometimes the template is the one mentioned at the very top of the page source.)

Hornstar 10-24-2010 07:41 PM

What kind of condition will do this.

If you are usergroup ID: X,Y,Z
If you are downloading attachment ID: X
Then display link
else display normal content.

Lynne 10-24-2010 08:25 PM

Sure, that is what I would try. is_member_of is the function you would use for the usergroup.

Hornstar 10-24-2010 08:41 PM

What is the function for the attachment ID part, that is the part I can't find currently.

Lynne 10-24-2010 10:36 PM

What template are you modifying? I would think they would have the variable name in there.

Hornstar 10-25-2010 05:56 AM

I think it is newpost_attachmentbit

In that template it has:
PHP Code:

<div style="margin:2px">
    <
img class="inlineimg" src="$attach[imgpath]alt="" border="0" />
    <
a href="attachment.php?$session[sessionurl]attachmentid=$attach[attachmentid]&amp;stc=1&amp;d=$attach[dateline]target="_blank">$attach[filename]</a>
    (
$attach[filesize])
</
div

Now this is probably mega wrong as I have not done much of this before, but does this look nearly right?

PHP Code:

<if condition="is_member_of($bbuserinfo, 2)">
and
<if 
condition="$attach['attachmentid'] == 41610">
<
div style="margin:2px">
    <
img class="inlineimg" src="$attach[imgpath]alt="" border="0" />
    <
a href="http://www.site.com/link">My Link</a>
    (
$attach[filesize])
</
div>
<else />
<
div style="margin:2px">
    <
img class="inlineimg" src="$attach[imgpath]alt="" border="0" />
    <
a href="attachment.php?$session[sessionurl]attachmentid=$attach[attachmentid]&amp;stc=1&amp;d=$attach[dateline]target="_blank">$attach[filename]</a>
    (
$attach[filesize])
</
div>
</if>
</if> 

I got that to save okay :) But then it did not change anything on the page which had that attachment

Any ideas?

Edit: I found where it was making the changes, if I click edit thread, than I will see the changes made on that page, and they worked perfect ^^, but I need them to show on the page where attachments are shown in a thread.

I tried these templates so far:
newpost_attachmentbit
attachmentbit
newattachmentbit
postbit_attachment
None of those worked in the spot I am trying, any idea which template I should edit for that?

Hornstar 10-26-2010 08:49 PM

I have it all working, except I can't find the correct template to put my code in. I tried "Add Template Name in HTML Comments" but that showed me a different part.

Any ideas of how I can find the correct template?

Lynne 10-27-2010 04:17 AM

The Add Template Name in HTML Comments will work if you look at the correct part of your page source. Get the attachment url and search for it in the page source and you will find it.

Hornstar 10-27-2010 10:48 AM

I took away the attachment if statement, and I re did what I did in every template again, and I found that this time it worked in the postbit_attachment template.

These are my if statements:
PHP Code:

<if condition="is_member_of($bbuserinfo, 2, 6)">
and
<if 
condition="$attach['attachmentid'] == 41668"

Now I noticed if I change my if statment to: <if condition="$attach['attachmentid'] != 41668">
Then it changes every attachment on the whole site to the code. so my problem is it picking up the actual attachmentid and seeing if it is true.

I am kind of stumped at this stage as I have even tried this if statement"
PHP Code:

<if condition="in_array($attach['attachmentid'], array(41668, 41669))"

Still with no success of it changing anything for those attachment with those IDs

Is there anything wrong with my if statements that you can see?


Also as an example.....This attachment: https://vborg.vbsupport.ru/attachmen...3&d=1263721711

The ID is: 109923 correct?

Because I have tried everything that I can possibly think of lol

Lynne 10-27-2010 01:54 PM

If you look at the postbit_attachment template, you'll see that the variable they are using is not $attach, it is $attachment. You need to use the correct variable name.

Hornstar 10-27-2010 08:44 PM

ic now. Thanks :)I will give that another go when I get home (You have helped me learn heaps so far tho)
It is working, but with one minor problem.
Every attachment now has the word 'and' showing. I think it may have something to do with my 2 if statements. Do I not need the word and between them? I removed the word 'and' and they seem to still be working.

Edit:
With my if statement, it is meant to show the special link to only registered users and the normal link to everyone else. However it is working good for registered users, but it is showing nothing to everyone else.

It is like my else statement is not working. any ideas?


All times are GMT. The time now is 04:03 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01090 seconds
  • Memory Usage 1,772KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (16)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete