vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Redirect links in new window (https://vborg.vbsupport.ru/showthread.php?t=68188)

welo 08-10-2004 12:30 PM

Redirect links in new window
 
Has anyone already devised a way to have an option where when a forum is a redirect link it opens in a new browser window? If not I'd appreciate some guidance on where I'd need to start looking to hack this in.

Preferably there would be an option in the forum manager directly under "Forum Link" for "New Window" or "Same Window". Otherwise just knowing where to tag in target="_blank" would help. Thanks.

CarCdr 08-10-2004 01:23 PM

This ain't pretty, but it should work...

Modify the template forumhome_forumbit_level2_nopost to output a different <a> tag. The default is to output a tag that points to forumdisplay.php, and in that script it notices that the forum is a link and send an HTTP header to change the LOCATION.

Anway, let's assume you want this only done for a certain forum, say, forumid of 12. In the forumhome_forumbit_level2_nopost template, change the line:
Code:

      <a href="forumdisplay.php?$session[sessionurl]f=$forum[forumid]">$forum[title]</a>
to:
Code:

      <if condition="$forum['link'] AND $forum['forumid']==12">
          <a href="$forum[link]" target="_blank">$forum[title]</a>
      <else />
          <a href="forumdisplay.php?$session[sessionurl]f=$forum[forumid]">$forum[title]</a>
      </if>


welo 08-10-2004 10:10 PM

Hey, thanks man. So what if there is more than one forum like this? Use:

Code:

<if condition="$forum['link'] AND $forum['forumid']==12, 15, 22, 27">
Maybe?

CarCdr 08-11-2004 12:54 AM

No. The stuff in <if condition="STUFF"> must be well formed PHP.

There are various ways to check that a single value, such as forumid, is a member of a set. Here's one that will work for you:
Code:

<if condition="$forum['link'] AND in_array($forum['forumid'], array(12, 15, 22, 26)">
This one means, "If the forum is of type link, then and only then, check that the forumid is one of the ones listed. If both these conditions are true, then include the HTML code.

welo 08-11-2004 01:27 PM

Ah, thanks again. I shoulda remembered that one because I used a similar array to make the "who viewed this thread" hack restricted to admin usergroups.

You're right about it being a little messy though. I'd hack this into my board but I'm also needing a similar solution for a client for sponsor and advertiser links, and this would be a bit much for them to grasp. I'll keep playing with it and see what I can do about adding something to the ACP to control it. I figure making something equal 1 in a new tinyint db field for target="_blank" and an if/else statement should do it.

vonedaddy 08-11-2004 01:47 PM

I have the opposite problem... My forum links open in a new window and I would like it to open in the same window... Any suggestions??

FYI my site is hereyah.com you can goto http://hereyah.com/forums/ and click on the links database to see what I mean

CarCdr 08-11-2004 02:07 PM

vonedaddy:
Different problem. You are using the "Links and Files Database" hack. welo is talking about forums that are defined to be links, a standard vB feature -- they are listed like other forums, but they are not really forums, just links to some URL.

ZnARk 09-17-2004 12:29 PM

As the newbie i am I have changed to

Code:

<if condition="$forum['link'] AND in_array($forum['forumid'], array(10, 12, 13, 14, 18, 15)">
          <a href="$forum[link]" target="_blank">$forum[title]</a>
      <else />
          <a href="forumdisplay.php?$session[sessionurl]f=$forum[forumid]">$forum[title]</a>
      </if>

but get
Quote:

Parse error: parse error in /web/pbnorr/web/forum/includes/adminfunctions_template.php(3055) : eval()'d code on line 14
When im trying to save.
Btw im using v3.0.3

Here is my original forumhome_forumbit_level2_nopost template and i want forum 10, 12, 13, 14, 18, 15 to open in new windows.
Code:

<tr>
        <td class="tcat"><span class="smallfont">&nbsp;</span></td>
        <td class="tcat" colspan="<if condition="$vboptions['showmoderatorcolumn']">5<else />4</if>">
                <a href="forumdisplay.php?$session[sessionurl]f=$forum[forumid]">$forum[title]</a>
                <if condition="$show['forumdescription']"><div class="smallfont">$forum[description]</div></if>
                <if condition="$show['subforums']"><div class="smallfont"><strong>$vbphrase[subforums]</strong>: $forum[subforums]</div></if>
        </td>
</tr>
$childforumbits


CarCdr 09-17-2004 06:38 PM

You are missing a closing parenthesis before the closing quote of the condition="" clause. You have one there to close array, but you need one to close in_array.


All times are GMT. The time now is 09:54 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.01114 seconds
  • Memory Usage 1,736KB
  • 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
  • (6)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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